Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ConditionalHandler<TIn, TOut>

This handler will pass all requests to the wrapped handler, until a specific value has been set in the given storage. After that all input will be rejected. Once the value has been matched this behaviour will be cached, so changing the value again afterwards will not enable this handler again.

Type parameters

  • TIn

  • TOut

Hierarchy

Index

Constructors

constructor

Properties

Private finished

finished: boolean

Private Readonly source

source: AsyncHandler<TIn, TOut>

Private Readonly storage

storage: KeyValueStorage<string, unknown>

Private Readonly storageKey

storageKey: string

Private Readonly storageValue

storageValue: unknown

Methods

canHandle

  • canHandle(input: TIn): Promise<void>
  • Checks if the input can be handled by this class. If it cannot handle the input, rejects with an error explaining why.

    Parameters

    • input: TIn

    Returns Promise<void>

    A promise resolving if the input can be handled, rejecting with an Error if not.

Private checkCondition

  • checkCondition(): Promise<void>

handle

  • handle(input: TIn): Promise<TOut>

handleSafe

  • handleSafe(input: TIn): Promise<TOut>