I have a canActivate ( guard ) where I am checking the loaded variable to see if the queue has loaded or not.
However I now need to check multiple queue loaded variable ( boolean ) to see if they have all loaded or not. I will need to dispatch actions then.
canActivate(): Observable < boolean > {
return this.checkStore().pipe(
switchMap(() => of(true)),
catchError(() => of(false))
);
}
checkStore(): Observable < boolean > {
// Below are the additional booleans I need to check on
// this.store.select(fromStore.isFirstQueueLoaded);
// this.store.select(fromStore.isSecondQueueLoaded);
// this.store.select(fromStore.isThirdQueueLoaded);
// this.store.select(fromStore.isFourthQueueLoaded);
// this.store.select(fromStore.isFifthQueueLoaded);
// this.store.select(fromStore.isSixthQueueLoaded);
// this.store.select(fromStore.isSeventhQueueLoaded);
return this.store.select(fromStore.isFirstQueueLoaded)
// want to check for remaining queues loaded boolean val here
.pipe(
tap(loaded => {
// need to check for loaded values of all queues
if (!loaded) {
this.dispatchActiontoStoreForAllQueue();
}
}),
filter(loaded => loaded)
);
}
dispatchActiontoStoreForAllQueue(): void {
this.store.dispatch(new fromStore.LoadFirstQueue({}));
this.store.dispatch(new fromStore.LoadSecondQueue({}));
this.store.dispatch(new fromStore.LoadthirdQueue({}));
this.store.dispatch(new fromStore.LoadFourthQueue({}));
this.store.dispatch(new fromStore.LoadFifthQueue({}));
this.store.dispatch(new fromStore.LoadSixthQueue({}));
this.store.dispatch(new fromStore.LoadSeventhQueue({}));
}
How do we combine all of these NGRX selects ( optimized approach ) to check on their booleans and activate the guard?