Skip to content

Latest commit

 

History

History
172 lines (131 loc) · 5.13 KB

docs.md

File metadata and controls

172 lines (131 loc) · 5.13 KB

Documentation is generated by JSDoc and jsdoc-to-markdown.


Functions

throwException(ex)

Returns a function that throws the passed exception, for use as argument for setTimeout

publish(message, data)Boolean

Publishes the message, passing the data to it's subscribers

publishSync(message, data)Boolean

Publishes the message synchronously, passing the data to it's subscribers

subscribe(message, func)String

Subscribes the passed function to the passed message. Every returned token is unique and should be stored if you need to unsubscribe

subscribeOnce(message, func)PubSub

Subscribes the passed function to the passed message once

clearAllSubscriptions()

Clears all subscriptions

clearAllSubscriptions()int

Clear subscriptions by the topic

countSubscriptions()Array

Count subscriptions by the topic

getSubscriptions()

Gets subscriptions by the topic

subscribeOnce(value)

Removes subscriptions

  • When passed a token, removes a specific subscription.

  • When passed a function, removes all subscriptions for that function

  • When passed a topic, removes all subscriptions for that topic (hierarchy)

throwException(ex)

Returns a function that throws the passed exception, for use as argument for setTimeout

Kind: global function

Param Type Description
ex Object An Error object

publish(message, data) ⇒ Boolean

Publishes the message, passing the data to it's subscribers

Kind: global function

Param Type Description
message String The message to publish
data The data to pass to subscribers

publishSync(message, data) ⇒ Boolean

Publishes the message synchronously, passing the data to it's subscribers

Kind: global function

Param Type Description
message String The message to publish
data The data to pass to subscribers

subscribe(message, func) ⇒ String

Subscribes the passed function to the passed message. Every returned token is unique and should be stored if you need to unsubscribe

Kind: global function

Param Type Description
message String The message to subscribe to
func function The function to call when a new message is published

subscribeOnce(message, func) ⇒ PubSub

Subscribes the passed function to the passed message once

Kind: global function

Param Type Description
message String The message to subscribe to
func function The function to call when a new message is published

clearAllSubscriptions()

Clears all subscriptions

Kind: global function
Access: public

clearAllSubscriptions() ⇒ int

Clear subscriptions by the topic

Kind: global function
Access: public

countSubscriptions() ⇒ Array

Count subscriptions by the topic

Kind: global function
Access: public

getSubscriptions()

Gets subscriptions by the topic

Kind: global function
Access: public

subscribeOnce(value)

Removes subscriptions

  • When passed a token, removes a specific subscription.

  • When passed a function, removes all subscriptions for that function

  • When passed a topic, removes all subscriptions for that topic (hierarchy)

Kind: global function
Access: public

Param Type Description
value String | function A token, function or topic to unsubscribe from

Example

// Unsubscribing with a token
var token = PubSub.subscribe('mytopic', myFunc);
PubSub.unsubscribe(token);

Example

// Unsubscribing with a function
PubSub.unsubscribe(myFunc);

Example

// Unsubscribing from a topic
PubSub.unsubscribe('mytopic');

© 2018 Morgan Roderick, http://roderick.dk/ <[email protected]>