TyphonEvents
Extends:
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 |
getEventbusName(): string | * Returns the current eventbusName. |
|
public |
setEventbusName(name: string): TyphonEvents Sets the eventbus name. |
|
public |
triggerAsync(name: string): Promise Provides |
|
public |
Defers invoking |
|
public |
triggerSync(name: string): * | Array<*> Provides |
Inherited Summary
From class Events | ||
private |
_events: * |
|
public |
bind(): * Delegates to |
|
public |
Tell an object to listen to a particular event on an other object. |
|
public |
Just like |
|
public |
Remove a previously-bound callback function from an object. |
|
public |
Bind a callback function to an object. |
|
public |
Just like |
|
public |
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 |
Public Constructors
public constructor(eventbusName: string) source
Provides a constructor which optionally takes the eventbus name.
Override:
Events#constructorParams:
Name | Type | Attribute | Description |
eventbusName | string | Optional eventbus name. |
Public Methods
public setEventbusName(name: string): TyphonEvents source
Sets the eventbus name.
Params:
Name | Type | Attribute | Description |
name | string | The name for this eventbus. |
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:
Name | Type | Attribute | Description |
name | string | Event name(s) |
public triggerDefer(): TyphonEvents source
Defers invoking trigger
. This is useful for triggering events in the next clock tick.
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:
Name | Type | Attribute | Description |
name | string | Event name(s) |