parzh / observable-to-async-generator

Convert an observable to ES6 async generator
https://npmjs.com/package/observable-to-async-generator
13 stars 2 forks source link
async async-generator await convert create function generator iterable iterator javascript observable otag rxjs typescript yield

observable-to-async-generator

Convert an observable to ES6 async generator.

Why observable-to-async-generator?

Import

import otag from "observable-to-async-generator";

… or:

const otag = require("observable-to-async-generator").default;

Usage

try {
    for await (const item of otag(observable)) {
        doSomethingWith(item);
    }
} catch (error) {
    handle(error);
}

Notes