@lacrypta/nomad v0.0.0 / EventCaster
Glob-enabled Event Caster interface.
This event caster allows listeners to be attached to “glob” expressions. All event names must adhere to the following ABNF:
segment = 1*( ALPHA / DIGIT / "/" / "_" / "." / "-" )
event-name = segment *( ":" segment )
.
An event name filter may use the following wildcards in lieu of a segment, with the restriction that no two consecutive filter segment may contain a “**” wildcard. Their expected meanings are as follows:
*
: matches any single segment
, cannot be empty.**
: matches zero or more segment
s, may be empty.This yields the following ABNF for a filter proper:
filter = ( ( segment / "*" ) [ ":" filter ] / "**" [ ":" segment [ ":" filter ] ] )
off(callback: EventCallback): this
Remove the given callback from the listeners set.
• callback: EventCallback
The callback to remove.
this
this
, for chaining.
on(filter: string, callback: EventCallback): this
Attach the given callback to the EventCaster, triggered on events matching the given filter.
• filter: string
Event name filter to assign the listener to.
• callback: EventCallback
Callback to call on a matching event being cast.
this
this
, for chaining.
once(filter: string, callback: EventCallback): this
Attach the given callback to the EventCaster, triggered on events matching the given filter, and removed upon being called once.
• filter: string
Event name filter to assign the listener to.
• callback: EventCallback
Callback to call on a matching event being cast.
this
this
, for chaining.