Home Manual Reference Source Repository
public class | source

TyphonEvents

Extends:

Events → TyphonEvents

Direct Subclass:

TyphonLoggedEvents

TyphonEvents adds new functionality for trigger events. The following are new trigger mechanisms:

Please refer to the Events documentation for all inherited functionality.

triggerDefer - Defers invoking trigger.

triggerFirst - Only invokes the first target matched and passes back any result to the callee.

triggerResults - Invokes all targets matched and passes back an array of results in an array to the callee.

triggerThen - Invokes all targets matched and adds any returned results through Promise.all which returns a single promise to the callee.

Method Summary

Public Methods
public

Returns the current eventbusName.

public

Sets the eventbus name.

public

Defers invoking trigger.

public

triggerFirst(name: string): *

Provides trigger functionality that only invokes the first target matched and passes back any result to the callee.

public

Provides trigger functionality, but collects any returned results from invoked targets in an array and passes back this array to the callee.

public

Provides trigger functionality, but collects any returned Promises from invoked targets and returns a single Promise generated by Promise.all.

Inherited Summary

From class Events
public

bind(): *

Delegates to on.

public

listenTo(obj: object, name: string, callback: function): Events

Tell an object to listen to a particular event on an other object.

public

listenToOnce(obj: object, name: string, callback: function): Events

Just like listenTo, but causes the bound callback to fire only once before being removed.

public

off(name: string, callback: function, context: object): Events

Remove a previously-bound callback function from an object.

public

on(name: string, callback: function, context: object): *

Bind a callback function to an object.

public

once(name: string, callback: function, context: object): *

Just like on, but causes the bound callback to fire only once before being removed.

public

stopListening(obj: object, name: string, callback: function): Events

Tell an object to stop listening to events.

public

Trigger callbacks for the given event, or space-delimited list of events.

public

unbind(): *

Delegates to off.

Public Methods

public getEventbusName(): string | * source

Returns the current eventbusName.

Return:

string | *

public setEventbusName(name: string) source

Sets the eventbus name.

Params:

NameTypeAttributeDescription
name string

The name for this eventbus.

public triggerDefer(): TyphonEvents source

Defers invoking trigger.

Return:

TyphonEvents

public triggerFirst(name: string): * source

Provides trigger functionality that only invokes the first target matched and passes back any result to the callee.

Params:

NameTypeAttributeDescription
name string

Event name(s)

Return:

*

public triggerResults(name: string): Array<*> source

Provides trigger functionality, but collects any returned results from invoked targets in an array and passes back this array to the callee.

Params:

NameTypeAttributeDescription
name string

Event name(s)

Return:

Array<*>

public triggerThen(name: string): Promise source

Provides trigger functionality, but collects any returned Promises from invoked targets and returns a single Promise generated by Promise.all. This is a very useful mechanism to invoke asynchronous operations over an eventbus.

Params:

NameTypeAttributeDescription
name string

Event name(s)

Return:

Promise