Home Manual Reference Source Repository
public class | source

TyphonLoggedEvents

Extends:

EventsTyphonEvents → TyphonLoggedEvents

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 debug and the eventbusName to 'unknown`.

Method Summary

Public Methods
public

Returns the any event scrubber function.

public

Returns the current log level.

public

setEventScrubber(eventScrubber: function)

Sets the current event scrubber.

public

setLogLevel(logLevel: string)

Sets the current log level.

public

Posts a log message given the current log level.

public

Defers invoking trigger.

public

triggerFirst(name: string): *

Posts a log message given the current log level.

public

Posts a log message given the current log level.

public

Posts a log message given the current log level.

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.

From class TyphonEvents
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.

Public Constructors

public constructor source

Constructs TyphonLoggedEvents and sets the default log level to debug and the eventbusName to 'unknown`.

Override:

Events#constructor

Public Methods

public getEventScrubber(): function source

Returns the any event scrubber function.

Return:

function

public getLogLevel(): string | * source

Returns the current log level.

Return:

string | *

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:

NameTypeAttributeDescription
eventScrubber function

A function that scrubs event log data.

public setLogLevel(logLevel: string) source

Sets the current log level.

Params:

NameTypeAttributeDescription
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#trigger

Params:

NameTypeAttributeDescription
name string

Event name(s)

See:

public triggerDefer(): TyphonLoggedEvents source

Defers invoking trigger.

Override:

TyphonEvents#triggerDefer

public 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#triggerFirst

Params:

NameTypeAttributeDescription
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#triggerResults

Params:

NameTypeAttributeDescription
name string

Event name(s)

Return:

Array<*>

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#triggerThen

Params:

NameTypeAttributeDescription
name string

Event name(s)

Return:

Promise