【发布时间】:2020-02-26 07:19:52
【问题描述】:
考虑到我有以下代码:
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);
})
)
我使用async 管道在我的模板中订阅。
我没想到这会起作用,但控制台的输出是:
> fired first
在我对 postAction$ 主题调用 .next() 之前,永远不会调用第一个 console.log('fired')。
RxJS 操作符的执行上下文是什么?它们是如何工作的?我原以为第一个排气图需要在运行其余运算符之前发出一个值。在 rxjs 中找不到任何东西 docs
stackblitz上的演示
【问题讨论】:
标签: angular rxjs rxjs-pipeable-operators