@yantrix/automata v0.6.0 • Docs
Yantrix API / @yantrix/automata / BasicEventBus
Class: BasicEventBus ​
Basic event bus class that is used in Yantrix automatas.
Extends ​
AbstractAutomataEventBus<number,Record<number,any>, typeofAbstractBaseClass,this> &AbstractBaseClass<this>
Implements ​
IAutomataEventBus<TAutomataBaseEventType,Record<TAutomataBaseEventType,any>>
Methods ​
_processEvents() ​
ts
_processEvents(): Promise<TAutomataEventStack<number, Record<number, any>>>Processes Events in the Event Stack and handles them using subscribed callbacks.
This method iterates over the Event Stack, invoking the corresponding callbacks for each valid Event, and processes a batch of Events limited by STACK_PROCESSING_BATCH_SIZE. When tasks repeatedly return more copies of their own Event ID than the batch consumed, limit their cumulative growth relative to the queue size after the first expanding batch. An isolated fan-out is allowed.
Returns ​
Promise<TAutomataEventStack<number, Record<number, any>>>
new Events acquired from processing the queue.
Throws ​
If the recursion limit, calculated as a ratio of the stack length, is exceeded for any Event.
Inherited from ​
createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass)._processEvents
clearEventStack() ​
ts
clearEventStack(): thisClear the event stack.
Returns ​
this
Implementation of ​
IAutomataEventBus.clearEventStack
Inherited from ​
createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).clearEventStack
dispatch() ​
ts
dispatch(...events): thisDispatch one or more events.
Parameters ​
• ...events: TAutomataEventStack<number, Record<number, any>>
The events to dispatch
Returns ​
this
This event bus instance
Implementation of ​
Inherited from ​
createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).dispatch
getEventStack() ​
ts
getEventStack(): TAutomataEventStack<number, Record<number, any>>Get the current event stack.
Returns ​
TAutomataEventStack<number, Record<number, any>>
The current event stack.
Implementation of ​
IAutomataEventBus.getEventStack
Inherited from ​
createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).getEventStack
isRunning() ​
ts
isRunning(): booleanCheck if the event bus is running.
Returns ​
boolean
True if the event bus is running, false otherwise.
Implementation of ​
Inherited from ​
createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).isRunning
pause() ​
ts
pause(): thisPause the event bus.
Returns ​
this
This event bus instance.
Implementation of ​
Inherited from ​
createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).pause
resume() ​
ts
resume(): thisResume the event bus.
Returns ​
this
This event bus instance.
Implementation of ​
Inherited from ​
createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).resume
subscribe() ​
ts
subscribe(event, callback): thisSubscribe to an event.
Parameters ​
• event: number
The event to subscribe to
• callback: TEventBusHandler<number, Record<number, any>>
The callback to call when the event is received
Returns ​
this
This event bus instance
Implementation of ​
Inherited from ​
createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).subscribe
unsubscribe() ​
ts
unsubscribe(event, callback): thisUnsubscribe from an event.
Parameters ​
• event: number
The event to unsubscribe from.
• callback: null | TEventBusHandler<number, Record<number, any>>
The callback function to unsubscribe.
Returns ​
this
This event bus instance.
Implementation of ​
Inherited from ​
createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).unsubscribe
whenIdle() ​
ts
whenIdle(): Promise<void>Resolves after the Event Stack and all asynchronous follow-up Events have been fully processed.
Returns ​
Promise<void>
Implementation of ​
Inherited from ​
createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).whenIdle