Check out this answer to understand the approach I am using for implementing the master guard. I have multiple guards that need to be executed in sequence.
In Master Guard -
return guard.canActivate(this.route, this.state);
The complete function is outlined below:
//Instantiate the guard and call canActivate method returning a promise
private activateGuard(guardKey: string): Promise<boolean> {
let guard: Guard1 | Guard2 | Guard3 | Guard4;
switch (guardKey) {
case GUARDS.GUARD1:
guard = new Guard1();
break;
case GUARDS.GUARD2:
guard = new Guard2();
break;
case GUARDS.GUARD3:
guard = new Guard3();
break;
case GUARDS.GUARD4:
guard = new Guard4(this._Guard4DependencyService);
break;
default:
break;
}
return guard.canActivate(this.route, this.state);
}
I encountered the following error:
Type 'boolean | Observable<boolean>' is not assignable to type 'boolean'.
Type 'Observable<boolean>' is not assignable to type 'boolean'.
You can find the stackblitz link here
Shared screenshot: https://i.sstatic.net/CskTp.png I would appreciate any help or solutions to resolve this error. Thank you!