StaticdefaultStaticdefaultSet the default Bus.options.thresholds for all instances.
StaticverboseSet the default Bus.options.verbose for all instances.
StaticdefaultThe active state of the bus, i.e. does it have any subscribers. Subscribers include delegates and scanners.
The bus's name, combining the configured options.name with the constructor name.
Whether the bus has any listeners, including those contributed by delegates.
Whether the bus has any listeners registered directly on it (excluding delegates).
Whether any listeners are contributed by delegate buses.
ProtectedhandleDeclare how the bus should handle events emitted that have no listeners.
Will be invoked when an instance's options.allowUnhandledEvents = false (default is true).
The default implementation is to throw an error.
Subscribe a callback to event(s). alias of Bus.proxy when invoked with WILDCARD, alias of Bus.any when invoked with an array of events
Handle multiple events with the same handler. MultiEventHandler receives raised event as first argument, payload as second argument
Create a proxy for all events raised. Like Bus.any, handlers receive the raised event as first argument and payload as second argument.
Utility for resolving/rejecting a promise based on the reception of an event. Promise will resolve with event payload, if a single event, or undefined if listening to multiple events.
what event/events should resolve the promise
OptionalrejectionTrigger: T extends "*"what event/events should reject the promise. Must be mutually disjoint with resolvingEvent
Utility for resolving/rejecting a promise based on an evaluation done when an event is triggered. If params.eager=true (default), evaluates condition immedately. If evaluator resolves or rejects in the eager evaluation, the scanner does not subscribe to any events
an evaluation function that should check for a certain state and may resolve or reject the scan based on the state.
event or events that should trigger evaluator
Optionaleager?: booleanshould params.evaluator be called immediately; default is true.
This eliminates the following anti-pattern:
if(!someCondition) {
await this.scan({evaluator: evaluateSomeCondition, trigger: ...});
}
Optionalpool?: booleanattempt to pool scanners that can be resolved by the same evaluator and trigger; default is true
Optionaltimeout?: numbercancel the scan after params.timeout milliseconds. Values <= 0 are ignored.
Currently pooling timeouts is not supported. If params.timeout is configured, it will disable pooling regardless if params.pool=true
Subscribe to meta states of the Bus, idle and active.
Bus becomes idle when it goes from 1 to 0 subscribers, and active when it goes from 0 to 1.
The handler receives a boolean indicating if the bus is active (true) or idle (false)
Remove all event subscribers, lifecycle subscribers, and delegates. Triggers lifecycle meta events for all subscribed events before removing lifecycle subscribers, emitting Lifecycle.willDestroy during teardown.
Set the default for
Bus.options.allowUnhandledEventsfor all instances.