Skip to main content

State

@webda/utils


Function: State()

State<E>(options?): (value, context) => void

Defined in: packages/utils/src/state.ts:83

Method decorator that automatically tracks state transitions on the instance.

On the outermost invocation of the decorated method, the state machine transitions:

  • to options.start (if provided) when the method begins
  • to options.end (if provided) when the method completes successfully
  • to options.error (if provided) when the method throws or rejects

Nested / recursive calls are counted and only the outermost call triggers transitions.

Type Parameters​

E​

E extends string = string

Parameters​

options?​

StateOptions<E>

Optional transition state names.

Returns​

the method decorator

(value, context) => void