Skip to content
Ron Hashimoto edited this page Aug 24, 2016 · 9 revisions

PubSub provides a queued event channel.

Usage

import {PubSub} from 'dripcap';

let pubsub = new PubSub();

pubsub.pub('loaded', 'hello');

pubsub.sub('loaded', (msg) => {
  console.log(msg);
});

let top = pubsub.get('loaded');

Reference

Methods

.pub (String channel, Any data, Integer queue = 1)

Enqueues the data to the channel.
Parameter queue specifies the maximum queue size. 0 means no limitation.

.sub (String channel, Function callback)

Receives data from the channel.

.get (String channel, Integer index = 0)

Get queued data from the channel.

Clone this wiki locally