Hello. Please, help me with problem.
I use ngStore in my project.
Part code of my project.
user$: Observable
customerCarList$: Observable
But, when I try use forkJoin, subsctibe haven't reaction on emit each Observable and both too.
Rx.Observable.forkJoin(
user$,
customerCarList$
).subscribe(val => {
console.log(val);
});
Please provide reproducible code to check in behavior. Also worth double check user$ and customerCarList$ both emits and completes.
Hey @pers1307! I recommend creating a reproducible example on stackblitz.com. Super easy to set up and super easy for other to debug.
forkJoin requires that the observable that is being forked also completes. In the case of @ngrx, all of their observables are usually based on a BehaviorSubject, and will never complete (under normal circumstances anyway).
In your case you either want to forkJoin(user$.take(1), customCarList$.take(1) or use a different operator that will react to changes such as combineLatest which will emit a value everytime one of the root observables emits.
Thank you so much @david-driscoll! Your approach is work. I understand it. Close issue please, @kwonoj.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
forkJoinrequires that the observable that is being forked alsocompletes. In the case of@ngrx, all of their observables are usually based on a BehaviorSubject, and will never complete (under normal circumstances anyway).In your case you either want to
forkJoin(user$.take(1), customCarList$.take(1)or use a different operator that will react to changes such ascombineLatestwhich will emit a value everytime one of the root observables emits.