A hook object with an execute property that contains a callback which returns a promise.

interface EventHook<T, R> {
    exec: ((payload: T) => Promise<void | R>);
    onFail?: ((payload: T) => Promise<void | R>);
    order?: number;
}

Type Parameters

  • T = any
  • R = any

Properties

Properties

exec: ((payload: T) => Promise<void | R>)

The callback method called when the hook is triggered.

Type declaration

    • (payload): Promise<void | R>
    • Parameters

      • payload: T

        The data which the callback has access to.

      Returns Promise<void | R>

      A promise of type R or void.

onFail?: ((payload: T) => Promise<void | R>)

The callback method which runs if a preceding action has been aborted, or has failed.

Type declaration

    • (payload): Promise<void | R>
    • Parameters

      • payload: T

        The data which the callback has access to.

      Returns Promise<void | R>

      A promise of type R or void.

order?: number

An optional property which defines the order in which the hooks run. If no order is defined, a value of 0 is assigned. Hooks run in ascending order.