zen-push
v0.3.1
Published
An Observable push stream
Downloads
1,465,322
Readme
zen-push
A push stream observable class. (Sometimes called a Subject in Rx-speak.)
Install
npm install zen-push
Usage
import PushStream from 'zen-push';
let pushStream = new PushStream();
pushStream.observable.subscribe(value => console.log(`Hello ${value}!`));
pushStream.next('World'); // 'Hello World!'
API
new PushStream()
let pushStream = new PushStream();
Creates a new PushStream
object.
pushStream.observable
pushStream.observable.subscribe(value => console.log(`Hello ${value}!`));
The instance of Observable used to listen to elements in the push stream.
pushStream.next(value)
pushStream.next('World');
Sends the next stream value to all observers.
pushStream.error(error)
pushStream.error(new Error('The planet as been destroyed'));
Sends an error to all observers. Calling this method terminates the stream.
pushStream.complete()
pushStream.complete();
Sends a signal to all observers that the stream is finished. Calling this method terminates the stream.
PushStream.multicast(observable)
let multicastObservable = PushStream.multicast(observable);
multicastObservable.subscribe(console.log);
multicastObservable.subscribe(console.log);
Uses a PushStream
to send an observable's values to multiple subscribers.