I have the following function that:
Take a value from my store => Transform it to csv => Create a download link
downloadCSV() {
let href;
this.store$.select(MissionsStoreSelectors.selectedRoute).pipe(take(1)).subscribe((route) => {
if (route) {
const csv = this.csvManipulatorService.generateCSVFromJSON({filename: route.routeId, data: route.waypoints, columns : ['id', 'position', 'rotation']});
href = this.domSanitizer.bypassSecurityTrustUrl('data:text/csv,' + encodeURIComponent(csv));
}
});
return href;
}
(don't take care about the fact there is no guard, is simplified)
I thought the subscribe was not synchronous. But from this accepted answer:
How to get current value of State object with @ngrx/store?
it looks like it is not.
My question is is this going to work 100% of the time? Is the subscribe with a take always synchronous ?