Documentation is generated by JSDoc and jsdoc-to-markdown.
- 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)
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 |
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 |
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 |
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 |
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 |
Clears all subscriptions
Kind: global function
Access: public
Clear subscriptions by the topic
Kind: global function
Access: public
Count subscriptions by the topic
Kind: global function
Access: public
Gets subscriptions by the topic
Kind: global function
Access: public
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]>