Promise based Observable proposal

Yad Smood y.s.inside at
Mon May 9 07:48:27 UTC 2016

Hi everyone,

I've been working on implementing a Promise based Observable proposal.

The main goal is to make the Observable composable, every subscribe will
return a new Observable, and every listener will try to resolve the
returned value as a Promise. Promise can't resolve multiple times, this
class makes it possible, so that you can easily map, filter and even back
pressure events in a promise way.

For live example: Double Click Demo

The implementation is here:

Code example:

var Observable = require("yaku/lib/Observable");
var linear = new Observable();

var x = 0;
setInterval(, 1000, x++);

// Wait for 2 sec then emit the next value.
var quad = linear.subscribe(async x => {
    await sleep(2000);
    return x * x;

var another = linear.subscribe(x => -x);

    value => { console.log(value); },
    reason => { console.error(reason); }

// Emit error
linear.error(new Error("reason"));

// Unsubscribe an observable.

// Unsubscribe all subscribers.
linear.subscribers = [];

The lib itself is on a very early stage, please leave a comment if you have
any idea on it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list