rxjs里concatMap operators的用法

简介: rxjs里concatMap operators的用法

Projects each source value to an Observable which is merged in the output Observable, in a serialized fashion waiting for each one to complete before merging the next.


将source Observable里的每个元素施加一个projection函数,这个projection函数返回一个新的Observable,然后将所有这些Observable flatten成另一个Observable.


image.png

Returns an Observable that emits items based on applying a function that you supply to each item emitted by the source Observable, where that function returns an (so-called “inner”) Observable. Each new inner Observable is concatenated with the previous inner Observable.


例子:


const clicks = fromEvent(document, 'click');

   const ioe = interval(1000);

   const mapfn = take(4);

   const comp = ioe.pipe(mapfn);

   const fn = ev => comp;

   const result = clicks.pipe( concatMap(fn));

   result.subscribe(x => console.log('diablo: ' +x));

image.pngimage.pngimage.pngimage.pngimage.png

目录
相关文章
|
10月前
|
缓存 JavaScript 前端开发
RxJS系列05:操作符 Operators(下)
RxJS系列05:操作符 Operators(下)
|
8月前
Rxjs TakeUntil 操作符的学习笔记
Rxjs TakeUntil 操作符的学习笔记
42 0
|
10月前
|
JavaScript 前端开发 Go
RxJS系列04:操作符 Operators(上)
RxJS系列04:操作符 Operators(上)
rxjs里debounceTime operators的用法
rxjs里debounceTime operators的用法
94 0
rxjs里debounceTime operators的用法
rxjs里mapTo operators的用法
rxjs里mapTo operators的用法
119 0
rxjs里mapTo operators的用法
rxjs里combineLatest operators的用法
rxjs里combineLatest operators的用法
95 0
rxjs里combineLatest operators的用法
|
JavaScript
rxjs里distinctUntilChanged operators的用法
rxjs里distinctUntilChanged operators的用法
98 0
rxjs里distinctUntilChanged operators的用法
rxjs里withLatestFrom operators的用法
rxjs里withLatestFrom operators的用法
96 0
rxjs里withLatestFrom operators的用法
rxjs里takeWhile operators的用法
rxjs里takeWhile operators的用法
95 0
rxjs里takeWhile operators的用法
rxjs里switchMap operators的用法
rxjs里switchMap operators的用法
171 0
rxjs里switchMap operators的用法