Interface: pubsub

syngen.utility.pubsub

Provides an interface for a publish-subscribe messaging pattern. Objects can be decorated with an existing or new instance with the static decorate method.

Source:
See:

Methods

(static) create() → {syngen.utility.pubsub}

Instantiates a new pubsub instance.

Source:
Returns:
Type
syngen.utility.pubsub

(static) decorate(target, instanceopt) → {Object}

Decorates target with a new or existing instance and returns it. This exposes its methods on target as if they are its own.

Parameters:
Name Type Attributes Description
target Object
instance syngen.utility.pubsub <optional>
Source:
Returns:
Type
Object

destroy()

Prepares the instance for garbage collection.

Source:

emit(event)

Dispatches event to all subscribers with optional ...data.

Parameters:
Name Type Attributes Description
event String
...data * <optional>
<repeatable>
Source:

off(eventopt, handleropt)

Unsubscribes handler from the handlers listening for event. If no handler is specified, then all handlers for event are removed. If no event is specified, then all handlers for all events are removed.

Parameters:
Name Type Attributes Description
event String <optional>
handler function <optional>
Source:

on(event, handler)

Subscribes handler to listen for event.

Parameters:
Name Type Description
event String
handler function
Source:

once(event, handler)

Subscribed handler to listen for event once. The handler is removed after its next dispatch.

Parameters:
Name Type Description
event String
handler function
Source: