Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LatchedSelector<S, E>

Sends an event to each child until one of them returns SUCCESS or RUNNING, then returns that value. If we exhaust all the children, return FAILURE. If a child returns RUNNING, subsequent events start at that child. 1/10/16

author

Joshua Chaitin-Pollak

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

  • getDebug(state: S): any
  • getLastEventSeen(state: S): undefined | number
  • getLastResult(state: S): undefined | string
  • getTreeEventCounter(state: S): any
  • handleChild(state: S, event: E, i: number): ResultCode
  • Recursively sends the event to each child until one of them returns success or running. If we exhaust all the children, return failure.

    Parameters

    • state: S

      The state when the event occured.

    • event: E

      The event to handle.

    • i: number

      The child index.

    Returns ResultCode

  • 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

  • precondition(state: S, event: E): boolean
  • resetNodeStorage(state: S): 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