Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Thought

Defines a process to wrap execution of middleware of the same name. Validators can prevent a process from running. Actions can effect the state before the next process validates.

Hierarchy

  • Thought

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

  • Create new thought process with optional validate and action functions. Presence of branches in options determines how middleware will execute. Without middleware option, will the middleware of same name as the thought. Create new thought process with optional validate and action functions. Presence of branches in options determines how middleware will execute. Without middleware option, will the middleware of same name as the thought.

    Parameters

    Returns Thought

Properties

b

b: State

Optional branches

branches: undefined | object

middleware

middleware: Middleware

name

name: string

Methods

action

  • action(_: boolean): Promise<void>

process

  • process(): Promise<any>
  • Call validate, execute middleware, possibly branches, then action. Will not enter process with empty branches or if state done is true. Without branches, execute middleware, resolve on completion. With branches, process each branch or until state done is true. Action will be called with the boolean success of the process. Process succeeds if middleware completed or branches were matched. If process succeeds, timestamp is added to state.

    Returns Promise<any>

validate

  • validate(): Promise<boolean>

Generated using TypeDoc