Contains any un-rescued sync or async errors from listeners.
Listener errors terminate their listener when unrescued, but are not propogated back
to the trigger call that prompted them, rather they are consumable via bus.errors
.
Errors in one listener do not affect the trigger-er, or any other listener.
In contrast, guard errors are raised to the trigger-er.
bus.errors.subscribe(ex => { console.error(ex) })
Private
eventsPrivate
filtersPrivate
guardsPrivate
handlingsPrivate
resetsPrivate
spiesPrivate
createRun a function synchronously for all runtime events, after guards, and prior to spies and listeners. A filter may modify, or replace an event. However the filter must return an event, or that event will not be seen by spies or listeners, and it will be as if the event was never triggered. This is what is meant to 'filter' out events. Throwing an exception will raise to the triggerer, but not terminate the filter.
A subscription that can be used to deactivate the filter.
Private
getRun a function synchronously for all runtime events, prior to all filters, spies and listeners. Throwing an exception will raise to the triggerer, but not terminate the guard.
A subscription that can be used to deactivate the guard.
Assigns a side-effect producing function to matching events in Concurrency Mode "Immediate".
Newly returned effects are begun immediately, and so may complete in any order (ala mergeMap
), or consume resources unboundedly.
A Subscription that can be used to unsubscribe the listener from future events. If the handler returned an Observable of work, any in-progress work will be canceled upon unsubscribe()
.
A predicate run upon every event on the bus. The handler function is only executed if the predicate returns true
. If the matcher provides a type guard, the handler will see its events as narrowed to that type.
The side-effect producing function which will "Return The Work", as an ObservableInput
(A Promise, Observable, or async generator)
Optional
observer: EffectObserver<HandlerReturnType>An EffectObserver which provides functions to be called upon notifications of the handler
Assigns a side-effect producing function to matching events in Concurrency Mode "Blocking" (aka singleton).
A new effect is not begun if one is in progress. (ala exhaustMap
).
A Subscription that can be used to unsubscribe the listener from future events. If the handler returned an Observable of work, any in-progress work will be canceled upon unsubscribe()
.
A predicate run upon every event on the bus. The handler function is only executed if the predicate returns true
. If the matcher provides a type guard, the handler will see its events as narrowed to that type.
The side-effect producing function which will "Return The Work", as an ObservableInput
(A Promise, Observable, or async generator)
Optional
observer: EffectObserver<HandlerReturnType>An EffectObserver which provides functions to be called upon notifications of the handler
Assigns a side-effect producing function to matching events in Concurrency Mode "Queueing".
Newly returned effects are enqueued and always complete in the order they were triggered (ala concatMap
).
A Subscription that can be used to unsubscribe the listener from future events. If the handler returned an Observable of work, any in-progress work will be canceled upon unsubscribe()
.
A predicate run upon every event on the bus. The handler function is only executed if the predicate returns true
. If the matcher provides a type guard, the handler will see its events as narrowed to that type.
The side-effect producing function which will "Return The Work", as an ObservableInput
(A Promise, Observable, or async generator)
Optional
observer: EffectObserver<HandlerReturnType>An EffectObserver which provides functions to be called upon notifications of the handler
Assigns a side-effect producing function to matching events in Concurrency Mode "Switching".
Any existing effect is canceled (if it is an Observable, not a Promise) before the new effect is begun (ala switchMap
).
A Subscription that can be used to unsubscribe the listener from future events. If the handler returned an Observable of work, any in-progress work will be canceled upon unsubscribe()
.
A predicate run upon every event on the bus. The handler function is only executed if the predicate returns true
. If the matcher provides a type guard, the handler will see its events as narrowed to that type.
The side-effect producing function which will "Return The Work", as an ObservableInput
(A Promise, Observable, or async generator)
Optional
observer: EffectObserver<HandlerReturnType>An EffectObserver which provides functions to be called upon notifications of the handler
Triggers effects upon matching events, using a Toggling (gate) Concurrency Strategy. A new effect is not begun if one is in progress, and the existing effect is canceled.
A subscription that can be used to unsubscribe the listener, thereby canceling work in progress.
A predicate run upon every event on the bus. The handler function is only executed if the predicate returns true
. If the matcher provides a type guard, the handler will see its events as narrowed to that type.
Called for each matching event, returns an ObservableInput (an Iterable,Promise,Observable)
Optional
observer: EffectObserver<HandlerReturnType>An EffectObserver which provides functions to be called upon notifications of the handler
Alias for trigger
Returns a Promise for the first event for which the predicate returns true
.
The returned Promise will be rejected upon a bus.reset
.
If the predicate is a type guard, the returned Promise will be narrowed to the matching type.
A predicate to select the first event for which it returns true
.
Creates an EffectObserver which triggers each value from the handler back onto the bus. Use this when the listener returns items suitable for putting directly onto the bus.
Creates an EffectObserver which triggers the handlers' lifecycle events, after running through a mapping function. Use this when the listener's values are not compatible with the bus, or to capture lifecycle events.
bus.listen(
isSearchRequest,
() => from([{ result: 'foo' }]),
bus.observeWith({ subscribe: () => ({ type: 'search/started' }) })
);
Returns an Observable of events for which the predicate returns true
.
The returned Observable completes upon a bus.reset
.
If the predicate is a type guard, the returned Observable will be narrowed to the matching type.
bus.query(() => true).subscribe(console.log)
A predicate to select events for which it returns true
.
Run a function (synchronously) for all runtime events, prior to all listeners. Throwing an exception will terminate the spy.
A subscription that can be used to deactivate the spy.
Puts an event onto the bus, firing any listeners whose predicate returns true
.
Events go first through guards, then filters, then spies, then listeners.
if a guard, or filter throws an exception. Listener exceptions or errors do not throw, but
appear on bus.errors
, and terminate that listener.
The item to send to listeners, once it clears guards, filters, and spies.
Generated using TypeDoc
A Bus instance provides transportation of events across any part of a browser, server, mobile or native app. The 𝗥𝘅𝑓𝑥 bus also allows type-safe ways of triggering, concurrency controlling, and canceling async side-effects in a framework-independent, pure JavaScript way, akin to RxJS.