Considering I have the following code:
private readonly postAction$ = new Subject();
postStream$ = this.postAction$.pipe(
exhaustMap(() => {
this.count ++;
console.log('fired')
return of('my other post');
}),
startWith(''),
exhaustMap(()=> {
this.count ++;
console.log('fired first')
return of('my post' + this.count);
})
)
Which I subscribe to in my template using the async
pipe.
I wasn't expecting this to work, but the output to the console was:
> fired first
Until I call .next()
on the postAction$
subject, the first console.log('fired')
is never called.
What's the execution context of RxJS operators? How do they work? I would have expected that the first exhaust map needed to emit a value, before the rest of the operators are ran. Couldn't find anything in the rxjs docs
Demo on stackblitz