天天看点

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.

rxjs里concatMap operators的用法

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));

rxjs里concatMap operators的用法
rxjs里concatMap operators的用法
rxjs里concatMap operators的用法
rxjs里concatMap operators的用法
rxjs里concatMap operators的用法

继续阅读