Reputation: 21104
I've got this piece of code:
myModel.tags
.filter(...)
.map(...)
.forEach(t => context.dispatch(new MyAction(t)))
dispatch
returns an Observable
.
I'd like to execute other RxJs code only when those Observable
s are all completed.
Is that possible?
Upvotes: 2
Views: 1078
Reputation: 96891
If you want to know when all Observables complete you have to collect all of them into an array and then use ideally forkJoin
:
const obs = myModel.tags
.filter(...)
.map(...)
.map(t => context.dispatch(new MyAction(t)))
const done$ = forkJoin(...obs).subscribe(...);
The forkJoin
observable creation method will emit just once with the array of all responses and then complete.
Upvotes: 2