Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LatchedIfElse<S, E>

Latched If-Else Latched Composite Node.

The conditional function is not called if the previous result was RUNNING - instead the saved result of calling the conditional is used until the consequent/alternative returns not RUNNING again and the state is reset

If conditional(state: S, event: E) returns true, control is passed to the consequent node.

If conditional(state: S, event: E) returns false, control is passed to the alternative node, or if alternative is a result code, that is returned, or if one is not provided, 'FAILURE' is returned.

06/23/21

author

Mark Asdoorian

Type Parameters

Hierarchy

Index

Constructors

Properties

name: string = ''
treePublisher: TreePublisher<any, any> = ...

Accessors

  • get id(): string
  • get latched(): boolean
  • get parent(): string
  • set parent(parent: string): void
  • Sets the parent of this Node, and all children Nodes.

    override

    Returns string

  • Sets the parent of this Node, and all children Nodes.

    override

    Parameters

    • parent: string

    Returns void

  • get path(): string
  • get symbol(): string

Methods

  • Returns the children of this node, i.e. the consequent and the optional alternative. this is to support the DOT & Archy visualizers see Composite<S,E>.addEventCounterToChildren

    Returns BaseNode<S, E>[]

  • getDebug(state: S): any
  • getLastEventSeen(state: S): undefined | number
  • getLastResult(state: S): undefined | string
  • getTreeEventCounter(state: S): any
  • initChildren(children: BaseNode<S, E>[]): void
  • Initializes the parent of our list of children. Only required to be called if you know your children at construction time. If your children are dynamic, then you are responsible for setting their parent properly when they are created. Note: this repeats code from set parent() because at construction time, this.children will not return anything (this isn't this yet), which is why we have to pass children in as a parameter

    Parameters

    • children: BaseNode<S, E>[]

      list of children to init (can't call getChildren() yet because this is called from the constructor)

    Returns void

  • If conditional resolves to true, then the consequent node handles the event. Otherwise, the alternative node handles the event. If no alternative is provided, this node resolves to FAILURE

    override

    Parameters

    • state: S

      The state when the event occured.

    • event: E

      The event to handle.

    Returns ResultCode

  • precondition(state: S, event: E): boolean
  • resetNodeStorage(state: S): any
  • Resets the storage unique to this Node, via the Node's path. If this node is a parent, then also reset all children.

    Parameters

    • state: S

    Returns any

  • registerNodeForDebug<S, E>(node: BaseNode<S, E>): void
  • registerTreePublisher<S, E>(publisher: TreePublisher<S, E>): void
  • unregisterNodeForDebug<S, E>(node: BaseNode<S, E>): void