import { Transition } from './transition'; import { StateMachineInfo } from './reflection/state-machine-info'; /** * Models behaviour as transitions between a finite set of states. * * @export * @class StateMachine * @template TState The type used to represent the states. * @template TTrigger The type used to represent the triggers that cause state transitions. */ export declare abstract class StateContext { /** * Provides an info object which exposes the states, transitions, and actions of this machine. * * @param {string} stateType * @param {string} triggerType * @returns {StateMachineInfo} * @memberof StateMachine */ abstract getInfo(stateType?: string, triggerType?: string): StateMachineInfo; /** * The current state. * * @memberof StateMachine */ /** * The initial state * * @type {TState} * @memberof StateMachine */ abstract state: TState; /** * The currently-permissible trigger values. * * @readonly * @type {Promise} * @memberof StateMachine */ abstract readonly permittedTriggers: Promise; /** * The currently-permissible trigger values. * * @param {...any[]} args * @returns {Promise} * @memberof StateMachine */ abstract getPermittedTriggers(...args: any[]): Promise; /** * Transition from the current state via the specified trigger. * The target state is determined by the configuration of the current state. * Actions associated with leaving the current state and entering the new one * will be invoked. * * @param {TTrigger} trigger The trigger to fire. * @returns {Promise} * @memberof StateMachine * @throws The current state does not allow the trigger to be fired. */ abstract fire(trigger: TTrigger, ...args: any[]): Promise; /** * Activates current state. Actions associated with activating the currrent state * will be invoked. The activation is idempotent and subsequent activation of the same current state * will not lead to re-execution of activation callbacks. * * @returns {Promise} * @memberof StateMachine */ abstract activate(): Promise; /** * Deactivates current state. Actions associated with deactivating the currrent state * will be invoked. The deactivation is idempotent and subsequent deactivation of the same current state * will not lead to re-execution of deactivation callbacks. * * @returns {Promise} * @memberof StateMachine */ abstract deactivate(): Promise; /** * Override the default behaviour of throwing an exception when an unhandled trigger * * @abstract * @param {(((state: TState, trigger: TTrigger, unmetGuards: string[]) => any | Promise) | * ((context: TContext, state: TState, trigger: TTrigger, unmetGuards: string[]) => any | Promise))} unhandledTriggerAction * @returns {*} * @memberof StateContext */ abstract onUnhandledTrigger(unhandledTriggerAction: ((state: TState, trigger: TTrigger, unmetGuards: string[]) => any | Promise) | ((context: TContext, state: TState, trigger: TTrigger, unmetGuards: string[]) => any | Promise)): any; /** * Determine if the state machine is in the supplied state. * * @param {TState} state * @returns {boolean} True if the current state is equal to, or a substate of, the supplied state. * @memberof StateMachine */ abstract isInState(state: TState): boolean; /** * Returns true if can be fired in the current state. * * @param {TTrigger} trigger Trigger to test. * @returns {boolean} True if the trigger can be fired, false otherwise. * @memberof StateMachine */ abstract canFire(trigger: TTrigger): Promise; /** * Registers a callback that will be invoked every time the statemachine transitions from one state into another. * * @param {((transition: Transition) => any | Promise)} onTransitionAction The action to execute, accepting the details * @returns {*} * @memberof StateMachine */ abstract onTransitioned(onTransitionAction: (transition: Transition) => any | Promise): any; } //# sourceMappingURL=state-context.d.ts.map