仅在另一个可观察到
我有代码的工作:
import { of } from 'rxjs';
import { map, takeWhile } from 'rxjs/operators';
const stream$ = of(3, 2, 1, 0, -1, -2, -3);
const ready$ = stream$.pipe(takeWhile((data) => data !== 0));
ready$.subscribe(console.log)
它将记录3、2、1。
如何创建一个可观察到的可观的$ stream
值,但仅在0
之后才得出。
换句话说:当准备就绪$
完成时,如何使可观察到流$
的值可观察到3、2、1、0?
I have working pieace of code:
import { of } from 'rxjs';
import { map, takeWhile } from 'rxjs/operators';
const stream$ = of(3, 2, 1, 0, -1, -2, -3);
const ready$ = stream$.pipe(takeWhile((data) => data !== 0));
ready$.subscribe(console.log)
It will log 3, 2, 1.
How to create an observable that emmits all $stream
values but only after 0
is emmited.
In other words: when ready$
completes, how to have observable that emmits values of stream$
except 3, 2, 1, 0?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需要用
skipwhile
替换,然后添加额外的skip(1)
才能忽略0You just have to replace
takeWhile
withskipWhile
and add an extraskip(1)
to ignore 0