Class FSMImpl<T>

A finite state machine that defines the behavior of a user interaction.

Type Parameters

Hierarchy

Implements

Constructors

Properties

_currentState: OutputState
_dataHandler: undefined | T
_log: boolean
_started: boolean

Goes with 'startingState'. It permits to know whether the FSM has started, ie whether the 'starting state' has been reached.

_states: State[]

The states that compose the finite state machine.

currentStatePublisher: Subject<[OutputState, OutputState]>
currentSubFSM: undefined | FSM

The current sub FSM in which this FSM is while running.

currentTimeout: undefined | TimeoutTransition

The current timeout in progress.

eventsToProcess: Event[]

The events still in process. For example when the user press key ctrl and scroll one time using the wheel of the mouse, the interaction scrolling is finished but the event keyPressed 'ctrl' is still in process. At the end of the interaction, these events are re-introduced into the state machine of the interaction for processing.

handlers: FSMHandler[]

The handlers to be notified on FSM state changes.

initState: InitState

The initial state of the FSM

inner: boolean

Defines whether the FSM is an inner FSM (ie, whether it is included into another FSM as a sub-FSM transition).

logger: Logger
startingState: State

By default an FSM triggers its 'start' event when it leaves its initial state. In some cases, this is not the case. For example, a double-click interaction is an FSM that must trigger its start event when the FSM reaches... its terminal state. Similarly, a DnD must trigger its start event on the first move, not on the first press. The goal of this attribute is to identify the state of the FSM that must trigger the start event. By default, this attribute is set with the initial state of the FSM.

Accessors

  • get log(): boolean
  • Logs (or not) information about the execution of the FSM.

    Returns boolean

  • set log(log): void
  • Logs (or not) information about the execution of the FSM.

    Parameters

    • log: boolean

    Returns void

Methods

  • Adds a standard state to the state machine.

    Parameters

    • name: string

      The name of the state to add.

    • startingState: boolean = false

      States whether the new state is the one that starts the FSM.

    Returns StdState

    The created state.

  • Adds a terminal state to the state machine.

    Parameters

    • name: string

      The name of the state to add.

    • startingState: boolean = false

      States whether the new state is the one that starts the FSM.

    Returns TerminalState

    The created state.

  • Checks whether the current state has a timeout transition. If it is the case, the timeout transition is launched.

    Returns void

  • Reinitialises the FSM. Compared to [[FSM#reinit]] this method flushes the remaining events to process.

    Returns void

  • Notifies handler that the interaction is cancelled.

    Returns void

  • Notifies handlers that an error occured.

    Parameters

    • err: unknown

      The error to handle

    Returns void

  • Notifies handler that the interaction starts.

    Returns void

  • Notifies handler that the interaction stops.

    Returns void

  • Notifies handler that the interaction updates.

    Returns void

  • Processes an error produced in the FSM.

    Parameters

    • err: unknown

      The error to treat.

    Returns void

  • Jobs to do when a timeout transition is executed. Because the timeout transition is based on a separated thread, the job done by this method must be executed in the UI thread. UI Platforms must override this method to do that.

    Returns void

  • Processes the provided event to run the FSM.

    Parameters

    • event: Event

      The event to process.

    Returns boolean

    True: the FSM correctly processed the event.

  • The end of the FSM execution, the events still (eg keyPress) in process must be recycled to be reused in the FSM.

    Returns void

  • Reinitialises the FSM. Remaining events to process are however not clear. See [[FSM#fullReinit]] for that.

    Returns void

  • Removes the given KeyPress event from the events 'still in process' list.

    Parameters

    • key: string

      The key code of the event to remove.

    Returns void

  • Uninstall the FSM. Useful for flushing memory. The FSM must not be used after that.

    Returns void

Generated using TypeDoc