As I create a guard in Angular, I am faced with the challenge of making two distinct HTTP requests and then deciding whether to continue based on both responses. After some research, I learned that forkJoin
is the recommended approach for this task, but for some reason mine doesn't seem to be working.
In my code implementation, I have:
this.userService.watchCurrentUser().subscribe(data => { console.log(data) });
this.orgService.watchOrg().subscribe(data => { console.log(data) });
Observable.forkJoin(
this.userService.watchCurrentUser(),
this.orgService.watchOrg()
).subscribe(data => {
console.log(data);
});
I added the first two subscriptions as an additional check to see if the calls were being executed, which they are since I can see the logs. However, I never get any output from the forkJoin
.
At the beginning of my file, I import it like so:
import { Observable, BehaviorSubject } from 'rxjs/Rx';
import 'rxjs/add/observable/forkJoin';
Could there be something essential that I'm overlooking when trying to use forkJoin
?