Skip to content

@yantrix/automata v0.0.2Docs


Yantrix API / @yantrix/automata / BasicEventBus

Class: BasicEventBus

Basic event bus class that is used in Yantrix automatas.

Extends

  • AbstractAutomataEventBus<number, Record<number, any>, typeof AbstractBaseClass, this> & AbstractBaseClass<this>

Implements

Methods

clearEventStack()

ts
clearEventStack(): this

Clear the event stack.

Returns

this

This event bus instance.

Implementation of

IAutomataEventBus.clearEventStack

Inherited from

createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).clearEventStack


dispatch()

ts
dispatch(...events): this

Dispatch one or more events.

Parameters

• ...events: TAutomataEventStack<number, Record<number, any>>

The events to dispatch.

Returns

this

This event bus instance.

Implementation of

IAutomataEventBus.dispatch

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(): boolean

Check if the event bus is running.

Returns

boolean

True if the event bus is running, false otherwise.

Implementation of

IAutomataEventBus.isRunning

Inherited from

createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).isRunning


pause()

ts
pause(): this

Pause the event bus.

Returns

this

This event bus instance.

Implementation of

IAutomataEventBus.pause

Inherited from

createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).pause


processEvents()

ts
processEvents(): TAutomataEventStack<number, Record<number, any>>

Process the events in the event stack.

Returns

TAutomataEventStack<number, Record<number, any>>

The processed event stack.

Implementation of

IAutomataEventBus.processEvents

Inherited from

createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).processEvents


resume()

ts
resume(): this

Resume the event bus.

Returns

this

This event bus instance.

Implementation of

IAutomataEventBus.resume

Inherited from

createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).resume


subscribe()

ts
subscribe(event, callback): this

Subscribe n to an event.

Parameters

event: number

The event to subscribe to.

callback: TEventBusHandler<number, Record<number, any>>

The callback function to call when the event is dispatched.

Returns

this

This event bus instance.

Implementation of

IAutomataEventBus.subscribe

Inherited from

createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).subscribe


unsubscribe()

ts
unsubscribe(event, callback): this

Unsubscribe 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

IAutomataEventBus.unsubscribe

Inherited from

createEventBus<TAutomataBaseEventType, Record<TAutomataBaseEventType, any>>()(AbstractBaseClass).unsubscribe