天天看點

rxjs的map和switchMap在SAP Spartacus中的應用 -将高階Observable進行flatten操作

rxjs裡switchMap operators的用法

通過rxjs的一個例子, 來學習SwitchMap的使用方法

rxjs switchMap的實作原理

rxjs的map和switchMap在SAP Spartacus中的應用 -将高階Observable進行flatten操作

Type Observable is not assignable to type Observable.

看這行代碼:

quantity$: Observable = this.product$.pipe(map(product => this.cartService.getEntry(product.code));傳回的參數類型是:Observable

rxjs的map和switchMap在SAP Spartacus中的應用 -将高階Observable進行flatten操作

使用switchMap就可以将嵌套的Observable打平, 是以switchMap也被稱為flatten operator.

rxjs的map和switchMap在SAP Spartacus中的應用 -将高階Observable進行flatten操作

繼續閱讀