getAvailableActions
getAvailableActions(
transitions
: {[key
:string
]:any
; },state
:string
):string
[]
Defined in: state-machine-actions.ts:14
Returns the list of available action/event types for a given state. Looks up the transition table for the specified state and returns its keys.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
transitions | {[key : string ]: any ; } | The transition table mapping states to possible events/actions. |
state | string | The current state key to query. |
Returns
Section titled “Returns”string
[]
An array of available action/event type strings for the state.
Source
Section titled “Source”This function is useful for determining what actions can be performed in a given state, allowing for dynamic UI updates or validation in applications using state machines. It retrieves the keys of the transition record for the specified state, which represent the available actions that can be triggered from that state.
export function getAvailableActions( transitions: { [key: string]: any }, state: string) { const entry = transitions[state]; return entry ? Object.keys(entry) : [];}