0.1.0 • Published 1 year ago

geneviv v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
1 year ago

geneviv

A new take on Observables using the generator interface as a core design abstraction.

Example

import { EventStream } from 'geneviv';

// Create an event stream that will send some number values
const stream = new EventStream(observer => {
  console.log('A new listener has been attached.');

  queueMicrotask(async function() {
    // Send some values to the listener. Note that we must
    // send values in a future turn of the event loop; the
    // event stream is not yet active when the init function
    // is called.
    observer.next(1);
    observer.next(2);

    await null;

    // Signal that the stream has ended. If we've returned
    // a cancel function from init, it will now be called.
    observer.return();
  });

  return () => {
    console.log('The listener has been detached.');
  };
});

// Transform the stream and attach a listener
stream.map(value => value * 2).listen(value => {
  console.log(`Next value is: ${ value }`);
});
0.1.0

1 year ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago