Options
All
  • Public
  • Public/Protected
  • All
Menu

Class State

A state represents a condition in a state machine that is the result of the triggers processed.

Hierarchy

  • State

Implements

Index

Constructors

constructor

  • new State(name: string, parent?: State | Region | undefined): State
  • Creates a new instance of the State class.

    Parameters

    • name: string

      The name of the state.

    • Default value parent: State | Region | undefined = undefined

      The parent region of the state or a state whose default region will be used as the parent region. If left undefined, this state is the root state in a state machine model.

    Returns State

Properties

children

children: Array<Region> = []

The child regions belonging to this state.

internal

defaultRegion

defaultRegion: Region | undefined

The default region used when creating state machine models with implicit regions.

internal

deferrableTrigger

deferrableTrigger: Array<Constructor<any>> = []

The list of types that this state can defer to the event pool.

internal

name

name: string

The name of the state.

onEnter

onEnter: Array<Consumer<any>> = []

The behaviour to each time the state is entered.

internal

onLeave

onLeave: Array<Consumer<any>> = []

The behaviour to perform each time the is state exited.

internal

outgoing

outgoing: Array<Transition> = []

The outgoing transitions available from this vertex.

internal

parent

parent: Region | undefined

The parent element of the state.

qualifiedName

qualifiedName: string

The fully qualified name of the vertex including its parent's qualified name.

Methods

defer

  • Marks a particular type of event for deferral if it is not processed by the state. Deferred events are placed in the event pool for subsiquent evaluation.

    Type parameters

    • TTrigger

    Parameters

    • type: Constructor<TTrigger>

      The type of event that this state will defer.

    Returns State

    Returns the state.

entry

  • Adds behaviour to the state to be called every time the state is entered.

    Parameters

    • action: Consumer<any>

      The behaviour to call on state entry.

    Returns this

    Returns the state.

exit

  • Adds behaviour to the state to be called every time the state is exited.

    Parameters

    • action: Consumer<any>

      The behaviour to call on state exit.

    Returns this

    Returns the state.

external

  • external<TTrigger>(target: Vertex): Transition<TTrigger>
  • Creates a new external transition.

    deprecated

    Use to method instead.

    Type parameters

    • TTrigger

      The type of the trigger event that may cause the transition to be traversed.

    Parameters

    • target: Vertex

      The target vertex of the external transition.

    Returns Transition<TTrigger>

    The external transition.

getDefaultRegion

  • getDefaultRegion(): Region
  • Returns the default state of the region; creates one if it does not already exist.

    Returns Region

    Returns the default region.

getTransition

  • getTransition(trigger: any): Transition | undefined
  • Returns the transition to take given a trigger event.

    throws

    Throws an Error if more than one transition was found.

    internal

    Parameters

    • trigger: any

      The trigger event.

    Returns Transition | undefined

    Returns the transition to take in response to the trigger, of undefined if none found.

internal

  • internal<TTrigger>(): Transition<TTrigger>
  • Creates a new internal transition.

    deprecated

    Use to method instead.

    Type parameters

    • TTrigger

      The type of the trigger event that may cause the transition to be traversed.

    Returns Transition<TTrigger>

    Returns the internal transition.

isComposite

  • isComposite(): boolean
  • Tests the state to see if it is a composite state (having one or more child regions).

    Returns boolean

    True if the state has one or more child regions.

isFinal

  • isFinal(): boolean
  • Returns true if the state is a final state. A final state is one that has no outgoing transitions therefore no more state transitions can occur in it's parent region.

    Returns boolean

isOrthogonal

  • isOrthogonal(): boolean
  • Tests the state to see if it is a composite state (having two or more child regions).

    Returns boolean

    True if the state has two or more child regions.

isSimple

  • isSimple(): boolean
  • Tests the state to see if it is a simple state (having no child regions).

    Returns boolean

    True if the state has no child regions.

local

  • local<TTrigger>(target: Vertex): Transition<TTrigger>
  • Creates a new local transition.

    deprecated

    Use to method instead.

    Type parameters

    • TTrigger

      The type of the trigger event that may cause the transition to be traversed.

    Parameters

    • target: Vertex

      The target vertex of the local transition.

    Returns Transition<TTrigger>

    Returns the local transition.

on

  • on<TTrigger>(type: Constructor<TTrigger>): Transition<TTrigger>

to

  • to<TTrigger>(target?: Vertex | undefined): Transition<TTrigger>
  • Creates a new external transition.

    Type parameters

    • TTrigger

      The type of the trigger event that may cause the transition to be traversed.

    Parameters

    • Default value target: Vertex | undefined = undefined

      The target vertex of the external transition.

    Returns Transition<TTrigger>

    If target is specified, returns an external transition otherwide an internal transition.

toString

  • toString(): string

when

  • when<TTrigger>(guard: Predicate<TTrigger>): Transition<TTrigger>
  • Creates a new internal transition with a guard condition.

    Type parameters

    • TTrigger

    Parameters

    • guard: Predicate<TTrigger>

      The guard condition to add.

    Returns Transition<TTrigger>

    Returns the new transition.

Generated using TypeDoc