@yantrix/automata v0.6.0 • Docs
Yantrix API / @yantrix/automata / IDataDestination
Interface: IDataDestination<EventType, EventMetaType, DataModel, DataPacketType, ResolveResultType, ErrorType> ​
Interface for dispatching data updates to external destinations with given rules and/or on specific events
Extends ​
IAgnosticDataDestination<DataPacketType,ResolveResultType,ErrorType>
Type Parameters ​
• EventType extends TAutomataBaseEventType
The base type of accepted events
• EventMetaType extends { [K in EventType]: any } = Record<EventType, any>
The metadata shape mapping for each event type
• DataModel extends object | null = object | null
The input data type (extends object | null)
• DataPacketType extends object = object
The data packet type for this destination
• ResolveResultType = void
An arbitrary type that is returned by transaction that actually delivers data
• ErrorType = Error
exception type
Properties ​
createTrigger() ​
ts
createTrigger: (events, selector) => this;Bind an update trigger to specific events, creating a data packet from Model diff
Parameters ​
• events: null | EventType[]
Event types to bind the selector to. Null means all events
• selector: TDataBoundSelector<EventType, EventMetaType, DataPacketType, DataModel>
Function that extracts Data Packet from Events and/or global Data Model
Returns ​
this
This destination instance
getBoundEvents() ​
ts
getBoundEvents: () => (null | EventType)[];Get all events that have triggers bound to them.
Returns ​
(null | EventType)[]
Array of event types that have triggers bound to them. Null means all events.
getTriggers() ​
ts
getTriggers: () => TDataBoundEventDictionary<EventType, EventMetaType, DataPacketType, DataModel>;Get all registered triggers
Returns ​
TDataBoundEventDictionary<EventType, EventMetaType, DataPacketType, DataModel>
Mapping of event types to their selector functions
id ​
ts
readonly id: string;Stable identifier for this destination. Used by consumers (e.g. CoreLoop) to key the registry.
Inherited from ​
isActive() ​
ts
isActive: () => boolean;Check if processing is active
Returns ​
boolean
True if actively processing data
Inherited from ​
IAgnosticDataDestination.isActive
removeTrigger() ​
ts
removeTrigger: (events) => this;Remove a previously registered trigger
Parameters ​
• events: null | EventType[]
Event types to remove the selector from. Null means all events
Returns ​
this
This destination instance
requestEmitter() ​
ts
requestEmitter: () => Generator<null | TDataDestinationOutput<DataPacketType, ResolveResultType, ErrorType>, any, any>;Returns an iterator over the data packets actually dispatched to the destination.
Returns ​
Generator<null | TDataDestinationOutput<DataPacketType, ResolveResultType, ErrorType>, any, any>
An iterator over data packets and dispatch results
Inherited from ​
IAgnosticDataDestination.requestEmitter
send() ​
ts
send: (data) => Promise<null | ResolveResultType>;Directly send a packet to the destination
Parameters ​
• data: DataPacketType
data packet to dispatch
Returns ​
Promise<null | ResolveResultType>
Promise resolved with declared resolve type
Inherited from ​
start() ​
ts
start: () => this;Start/resume data processing
Returns ​
this
This destination instance
Inherited from ​
IAgnosticDataDestination.start
stop() ​
ts
stop: () => this;Stop/pause data processing
Returns ​
this
This destination instance
Inherited from ​
update() ​
ts
update: (event, model?) => null | DataPacketType[];dispatch the event to destination, invoking all attached triggers and updating the destination
Parameters ​
• event: TAutomataEventMetaType<EventType, EventMetaType>
Event to process
• model?: DataModel
New data model to process
Returns ​
null | DataPacketType[]
This sent data packet