如何使用 multicast()
运算符和RxJS 5.5中使用 pipe()
而不是链接运算符的新推荐方法?当我尝试像之前一样使用_736757时,我收到TypeScript错误:
const even$ = new Subject();
const connectedSub = interval(500)
.pipe(
filter(count => count % 2 === 0),
take(5),
multicast(even$)
)
.connect();
even$.subscribe(value => console.log(value));
此代码有效,但产生一个TypeScript错误报告 Property 'connect' does not exist on type 'Observable<{}>'.
我是否使用可连接的observables,我应该在RxJS 5.5中?
1 回答
当前-v5.5.10和v6.1.0 -
pipe
的类型不知道Observable
子类,所以我使用类型断言,如下所示: