zen-push

An Observable push stream

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
zen-push
900.3.1a month ago5 years agoMinified + gzip package size for zen-push in KB

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.