@yantrix/automata v0.0.1 • Docs
Yantrix API / @yantrix/automata / IStateDictionary
Interface: IStateDictionary<StateType, ContextType>
Interface for a dictionary of states.
Extends
IAutomataExtendedStateContainer
<StateType
,ContextType
>
Type Parameters
• StateType extends TAutomataBaseStateType
The type of state.
• ContextType extends { [K in StateType]: any }
= Record
<StateType
, any
>
The type of context.
Properties
addContextTransformer()
ts
addContextTransformer: <T>(state, transformer, namespace?) => string;
add a Context Transformer for a particular State, possibly scoped to namespace
Type Parameters
• T extends number
Parameters
• state: T
• transformer: TContextTransformer
<T
, ContextType
>
to add
• namespace?: string
Returns
string
transformer ID
addStates()
ts
addStates: (params) => StateType[];
add new string States to the Dictionary, possibly within namespace
Parameters
• params: TStateKeysCollection
<StateType
>
Returns
StateType
[]
new States' values
clearStates()
ts
clearStates: (namespace?) => this;
remove all States from the Dictionary, possibly scoping them to namespace.
Parameters
• namespace?: string
Returns
this
getContextTransformers()
ts
getContextTransformers: (namespace?) => Partial<{ [K in number]: Record<string, TContextTransformer<K, ContextType>> }>;
Get all Context Transformers grouped by a particular State, possibly scoped to namespace
Parameters
• namespace?: string
Returns
Partial
<{ [K in number]: Record<string, TContextTransformer<K, ContextType>> }
>
getDictionary()
ts
getDictionary: (namespace?) => TStateDictionaryMapping<StateType>;
Get all mapped State Types with their corresponding Keys, possibly filtered by Namespace
Parameters
• namespace?: string
Returns
TStateDictionaryMapping
<StateType
>
getStateKeys()
ts
getStateKeys: (states) => (null | string)[];
Get Keys for selected States, possibly scoped to namespace
Parameters
• states: TStateValuesCollection
<StateType
>
Returns
(null
| string
)[]
getStateValues()
ts
getStateValues: (states) => (null | StateType)[];
Get all States for selected Keys, possibly scoped to namespace
Parameters
• states: TStateKeysCollection
<StateType
>
Returns
(null
| StateType
)[]
removeContextTransformer()
ts
removeContextTransformer: <T>(state, transformer, namespace?) => this;
remove a Context Transformer for a particular State, possibly scoped to namespace
Type Parameters
• T extends number
Parameters
• state: T
• transformer: TContextTransformer
<T
, ContextType
>
to remove
• namespace?: string
Returns
this
removeContextTransformerById()
ts
removeContextTransformerById: (id) => this;
remove a Context Transformer by ID
Parameters
• id: string
Returns
this
removeStates()
ts
removeStates: (params, removeContextTransformers?) => this;
remove States from the Dictionary, possibly scoping them to namespace.
Parameters
• params: TStateLookupParams
<StateType
>
• removeContextTransformers?: boolean
if true, also remove Context Transformers for removed States
Returns
this
runContextTransformers()
ts
runContextTransformers: <T>(id, context) => TAutomataStateContext<StateType, ContextType>;
Run all Context Transformers for a particular State, possibly scoped to namespace
Type Parameters
• T extends number
Parameters
• id: string
• context: TAutomataStateContext
<T
, ContextType
>
Returns
TAutomataStateContext
<StateType
, ContextType
>