I have a route guard in my application in which i need to check for two observables if anyone is success i should allow the route or block.
Route guard :
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): any {
return (this.isValid().map(valid => {
console.log(valid);
return valid;
}) || this.isValidFromApi().map(valid => {
console.log(valid);
return valid;
}));
} //how to achieve something like this
}
private isValid() {
return this.service.details.map(resp => {
console.log(resp);
if (resp.data) {
return true;
} else {
return false;
}
});
}
private isValidFromApi() {
return this.service.getKeys().map((response) => {
console.log(response);
if (response) {
return true;
} else {
return false;
});
}
So if anyone of isValid() or isValidFromApi() return true the route guard canActivate should be active. How to achieve this? I don't want to wait for both the calls to complete because this.service.details is actually a BehaviorSubject which holds the response of this.service.getKeys().
Is there any other way to achieve this??
Thanks in advance