@bensjoberg/rxjs-async-map
    TypeScript icon, indicating that this package has built-in type declarations

    0.3.0 • Public • Published

    rxjs-async-map

    Map an observable using an async function with a configurable concurreny level, while preserving element order.

    CircleCI Greenkeeper badge

    Installation

    rxjs-async-map is available via npm or yarn:

    npm i --save rxjs-async-map
    
    yarn add rxjs-async-map
    

    Usage

    import { of } from 'rxjs/observable/of';
    import { asyncMap } from 'rxjs-async-map';
    
    const myPromise = val =>
      new Promise(resolve => setTimeout(() => resolve(`Result: ${val}`), Math.random() * 1000));
    
    const source = of(1, 2, 3);
    
    // Map over the observable using the async function, while running
    // up to two promises concurrently.
    //
    // The order of elements is preserved, even if the promises resolve
    // out-of-order.
    const example = source.pipe(asyncMap(myPromise, /* concurrency: */ 2));
    
    /*
      output:
      "Result: 1"
      "Result: 2"
      "Result: 3"
    */
    const subscribe = example.subscribe(val => console.log(val));

    License

    MIT

    Keywords

    none

    Install

    npm i @bensjoberg/rxjs-async-map

    DownloadsWeekly Downloads

    0

    Version

    0.3.0

    License

    MIT

    Unpacked Size

    141 kB

    Total Files

    23

    Last publish

    Collaborators

    • bensjoberg