Home Manual Reference Source Test Repository
public class | source

TyphonEvents

Extends:

Events → TyphonEvents

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

triggerDefer - Defers invoking trigger.

triggerSync - Invokes all targets matched and passes back a single result or an array of results in an array to the callee.

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

Please refer to the Events documentation for all inherited functionality.

Constructor Summary

Public Constructor
public

constructor(eventbusName: string)

Provides a constructor which optionally takes the eventbus name.

Member Summary

Private Members
private

Stores the name of this eventbus.

Method Summary

Public Methods
public

Returns the current eventbusName.

public

Sets the eventbus name.

public

Provides trigger functionality, but collects any returned Promises from invoked targets and returns a single Promise generated by Promise.resolve for a single value or Promise.all for multiple results.

public

Defers invoking trigger.

public

triggerSync(name: string): * | Array<*>

Provides trigger functionality, but collects any returned result or results from invoked targets as a single value or in an array and passes it back to the callee in a synchronous manner.

Inherited Summary

From class Events
private

_events: *

public

bind(): *

Delegates to on.

public

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

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

public

listenToOnce(obj: object, name: string, callback: function, context: object): 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, context: object): 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 Constructors

public constructor(eventbusName: string) source

Provides a constructor which optionally takes the eventbus name.

Override:

Events#constructor

Params:

NameTypeAttributeDescription
eventbusName string

Optional eventbus name.

Private Members

private _eventbusName: string source

Stores the name of this eventbus.

Public Methods

public getEventbusName(): string | * source

Returns the current eventbusName.

Return:

string | *

public setEventbusName(name: string): TyphonEvents source

Sets the eventbus name.

Params:

NameTypeAttributeDescription
name string

The name for this eventbus.

Return:

TyphonEvents

public triggerAsync(name: string): Promise source

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

Params:

NameTypeAttributeDescription
name string

Event name(s)

Return:

Promise

public triggerDefer(): TyphonEvents source

Defers invoking trigger. This is useful for triggering events in the next clock tick.

Return:

TyphonEvents

public triggerSync(name: string): * | Array<*> source

Provides trigger functionality, but collects any returned result or results from invoked targets as a single value or in an array and passes it back to the callee in a synchronous manner.

Params:

NameTypeAttributeDescription
name string

Event name(s)

Return:

* | Array<*>