Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Branch

Process message in state and decide whether to act on it.

Hierarchy

Implements

Indexable

[key: string]: any

Process message in state and decide whether to act on it.

Index

Constructors

constructor

  • Create a Branch Create a Branch

    Parameters

    Returns Branch

Properties

callback

callback: ICallback

Action to take on matching input.

force

force: boolean = false

Force matching on this branch regardless of other matched branches.

id

id: string

Optional match

match: any

The result of branch matcher on input.

Optional matched

matched: undefined | false | true

Status of match.

processKey

processKey: ProcessKeys = "listen"

The thought process collection the branch should be applied.

type

  • get type(): string

Methods

execute

  • Runs the matcher, then middleware and callback if matched. Middleware can intercept and prevent the callback from executing. If the state has already matched on prior branch, it will not match again unless forced to, with the branch's force property.

    Parameters

    • b: State

      State containing message to process

    • middleware: Middleware

      Executes before the branch callback if matched

    • Optional done: IDone

      Called after middleware (optional), with match status

    Returns Promise<State>

Abstract matcher

  • matcher(input: any): Promise<any>
  • matcher(input: any): Promise<any>
  • Parameters

    • input: any

    Returns Promise<any>

  • Determine if this branch should trigger the callback. Note that the method must be async, custom matcher will be promise wrapped. Abstract input has no enforced type, but resolved result MUST be truthy.

    Parameters

    • input: any

    Returns Promise<any>

Generated using TypeDoc