zen-push
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/zen-push package

0.3.1 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i zen-push

Weekly Downloads

400,927

Version

0.3.1

License

MIT

Unpacked Size

9.17 kB

Total Files

7

Last publish

Collaborators

  • zenparsing