I am trying to use a resolver in order to retrieve data depending on the given parameters the route holds.
Unfortunately, the moment I add another data stream that my da
Observable only get executed when you call Observable.subscribe()
explicitly . I don't see anywhere in your code where you are subscribing to your Observables.
Note : Concept of resolve is related to Promise not with Observable.
Try :
export class MyResolver {
constructor(_secondService: SecondService, _myService: MyService) {}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable {
// Does not work - Simply does not resolve
return this._secondService
.observable()
.pipe(
take(1),
switchMap((bar) => this._myService.get(bar)),
}
);
// WORKS
return of(new Foobar('sampleData')).pipe(
take(1),
switchMap((bar) => this._myService.get(bar)),
});
}
}
Subscribe where you need the result.