Skip to content

@yantrix/automata v0.6.0 • Docs


Yantrix API / @yantrix/automata / EffectScheduler

Class: EffectScheduler<ModelType, EventType, EventMetaType> ​

Transactional Effect Layer for the Yantrix Main Loop.

Events are enqueued while FSM Reducers run. flush() applies all matching Effects in deterministic order and performs at most one Data Model commit. The Main Loop owns the batch boundary and is expected to call flush() once after it has finished processing its emitted Events.

Type Parameters ​

• ModelType extends object

• EventType extends TAutomataBaseEventType = TAutomataBaseEventType

• EventMetaType extends { [K in EventType]: any } = Record<EventType, any>

Implements ​

Accessors ​

pendingCount ​

ts
get pendingCount(): number

Number of Events waiting for the next Main Loop batch boundary.

Returns ​

number

Implementation of ​

IEffectScheduler.pendingCount

Methods ​

addMatrix() ​

ts
addMatrix(matrix): TSubscriptionCancelFunction

Registers a Slice's Effect Matrix. The Effect Matrices and their Effects are evaluated in registration and declaration order.

Parameters ​

• matrix: TEffectMatrix<ModelType, EventType, EventMetaType>

Returns ​

TSubscriptionCancelFunction

Implementation of ​

IEffectScheduler.addMatrix


clear() ​

ts
clear(): this

Discards the current, not-yet-flushed batch.

Returns ​

this

Implementation of ​

IEffectScheduler.clear


enqueue() ​

ts
enqueue(event): this

Adds an emitted Event to the current Main Loop batch.

Parameters ​

• event: TAutomataEventMetaType<EventType, EventMetaType>

Returns ​

this

Implementation of ​

IEffectScheduler.enqueue


flush() ​

ts
flush(): TEffectFlushResult<ModelType>

Applies the current batch atomically and commits no more than one snapshot. A failed Effect consumes its batch but leaves the store unchanged.

Returns ​

TEffectFlushResult<ModelType>

Implementation of ​

IEffectScheduler.flush