我最近从Angular 5更新到Angular 6.
我收到了这个警告combineLatest is deprecated: resultSelector no longer supported, pipe to map instead.Rxjs是版本6.1.0,tslint是5.10.0,Angular CLI是6.0.0和Typescript 2.7.2.我这样使用它:
const a$ = combineLatest(
this.aStore.select(b.getAuth),
this.cStore.select(b.getUrl),
(auth, url) => ({auth, url}),
);
Run Code Online (Sandbox Code Playgroud)
我也尝试过这样:
empty().pipe(
combineLatest(...),
...
)
Run Code Online (Sandbox Code Playgroud)
但是这给了我:combineLatest is deprecated: Deprecated in favor of static combineLatest而且对于静态版本也不推荐使用empty.
是否可以在链中取消 Observable?假设我们有一些相互依赖的事件链,如果其中一个事件链失败,则无需继续。
observable_1.pipe(
take(1),
switchMap((result_1) => {
// Do something that requires observable_1 and return something
// If it fails, there is no point to proceed
// If it succeeds, we can continue
}),
switchMap((result_2) => {
// Do something that requires result_2 and return something
// If it fails, there is no point to proceed
// If it succeeds, we can continue
}),
// etc...
);
Run Code Online (Sandbox Code Playgroud)