rxjs的map和switchMap在SAP Spartacus中的应用

时间:2022-07-25
本文章向大家介绍rxjs的map和switchMap在SAP Spartacus中的应用,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

Type Observable<Observable> is not assignable to type Observable.

看这行代码:

quantity$: Observable<number> = this.product$.pipe(map(product => this.cartService.getEntry(product.code));

返回的参数类型是:Observable<Observable>

使用switchMap就可以将嵌套的Observable打平。