import TyphonLoggedEvents from 'typhonjs-core-backbone-events-logged/src/TyphonLoggedEvents.js'
TyphonLoggedEvents
Extends:
TyphonLoggedEvents posts a message to the logger
before invoking the parent TyphonEvents method.
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 promises through Promise.all which returns
a single promise to the callee.
Constructor Summary
Public Constructor | ||
public |
Constructs TyphonLoggedEvents and sets the default log level to |
Method Summary
Public Methods | ||
public |
Returns the any event scrubber function. |
|
public |
getLogLevel(): string | * Returns the current log level. |
|
public |
setEventScrubber(eventScrubber: function) Sets the current event scrubber. |
|
public |
setLogLevel(logLevel: string) Sets the current log level. |
|
public |
trigger(name: string): TyphonLoggedEvents Posts a log message given the current log level. |
|
public |
Defers invoking |
|
public |
triggerFirst(name: string): * Posts a log message given the current log level. |
|
public |
triggerResults(name: string): Array<*> Posts a log message given the current log level. |
|
public |
triggerThen(name: string): Promise Posts a log message given the current log level. |
Inherited Summary
From class Events | ||
public |
bind(): * Delegates to |
|
public |
Tell an object to listen to a particular event on an other object. |
|
public |
listenToOnce(obj: object, name: string, callback: function): Events Just like |
|
public |
Remove a previously-bound callback function from an object. |
|
public |
Bind a callback function to an object. |
|
public |
Just like |
|
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 |
From class TyphonEvents | ||
public |
getEventbusName(): string | * Returns the current eventbusName. |
|
public |
setEventbusName(name: string) Sets the eventbus name. |
|
public |
Defers invoking |
|
public |
triggerFirst(name: string): * Provides |
|
public |
triggerResults(name: string): Array<*> Provides |
|
public |
triggerThen(name: string): Promise Provides |
Public Constructors
public constructor source
Constructs TyphonLoggedEvents and sets the default log level to debug
and the eventbusName to 'unknown`.
Override:
Events#constructorPublic Methods
public setEventScrubber(eventScrubber: function) source
Sets the current event scrubber. The event scrubber is a function which is passed the logData
object hash
of event data that is about to be logged. It should pass back a modified version of logData
. This is rather
useful for scrubbing sensitive events from being logged such as username / password.
Params:
Name | Type | Attribute | Description |
eventScrubber | function | A function that scrubs event log data. |
public setLogLevel(logLevel: string) source
Sets the current log level.
Params:
Name | Type | Attribute | Description |
logLevel | string | The log level to set. |
public trigger(name: string): TyphonLoggedEvents source
Posts a log message given the current log level.
Trigger callbacks for the given event, or space-delimited list of events. Subsequent arguments to trigger will be passed along to the event callbacks.
Override:
Events#triggerParams:
Name | Type | Attribute | Description |
name | string | Event name(s) |
public triggerDefer(): TyphonLoggedEvents source
Defers invoking trigger
.
Override:
TyphonEvents#triggerDeferpublic triggerFirst(name: string): * source
Posts a log message given the current log level.
Provides trigger
functionality that only invokes the first target matched and passes back any result to
the callee.
Override:
TyphonEvents#triggerFirstParams:
Name | Type | Attribute | Description |
name | string | Event name(s) |
Return:
* |
public triggerResults(name: string): Array<*> source
Posts a log message given the current log level.
Provides trigger
functionality, but collects any returned results from invoked targets in an array and passes
back this array to the callee.
Override:
TyphonEvents#triggerResultsParams:
Name | Type | Attribute | Description |
name | string | Event name(s) |
public triggerThen(name: string): Promise source
Posts a log message given the current log level.
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.
Override:
TyphonEvents#triggerThenParams:
Name | Type | Attribute | Description |
name | string | Event name(s) |