Class: PubSub

PubSub()

This class implements a publish/subscribe broker that can be used to passively receive updates. This would typically be used with a technology such as WebSockets or an HTML5 postMessage.

Constructor

new PubSub()

Source:

Methods

publish(topic, payload) → {void}

Parameters:
Name Type Description
topic * The topic for the payload to be published on.
payload * The payload that will be published.
Source:
Returns:
Type
void

subscribe(topic, key, callback) → {void}

Parameters:
Name Type Description
topic * The topic of interest.
key * The value that is used to uniquely identify the callback.
callback handlePayload The callback that will be ran when a payload is published.
Source:
Returns:
Type
void

unsubscribe(topic, key) → {boolean}

Parameters:
Name Type Description
topic * The topic that should be unsubscribed from.
key * The key that was used when subscribing.
Source:
Returns:
True if the unsubscription was successful, false otherwise.
Type
boolean