Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Branch

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

Hierarchy

Indexable

[key: string]: any

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

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

callback

callback: IBranchCallback

force

force: boolean = false

id

id: string

Optional match

match: any

Optional matched

matched: undefined | true | false

Methods

Abstract matcher

  • matcher(input: any): 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>

process

  • 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

    • Default value done: IBranchDone = () => null

      Called after middleware (optional), with match status

    Returns Promise<State>

Generated using TypeDoc