Class HooksEmitter<T>

A registry for managing and executing lifecycle hooks. Handlers are executed sequentially in registration order.

While built-in hooks are defined in ClideHooks, custom hooks can be registered using any string as the hook name.

Type Parameters

  • T extends AnyObject = ClideHooks

    The hooks configuration object

Constructors

Methods

Constructors

Methods

  • Call all handlers registered for a hook. Handlers are called sequentially in registration order.

    Type Parameters

    • THook extends
          | string
          | number
          | symbol
          | string & {}

    Parameters

    • hook: THook

      The hook to call

    • Rest...args: Parameters<HookHandler<THook, T>>

      Arguments to pass to each handler

    Returns Promise<void>

  • Remove a previously registered handler.

    Type Parameters

    • THook extends
          | string
          | number
          | symbol
          | string & {}

    Parameters

    • hook: THook

      The hook to remove the handler from

    • handler: HookHandler<THook, T>

      The handler to remove

    Returns boolean

    true if the handler was found and removed

  • Register a handler for a hook.

    Type Parameters

    • THook extends
          | string
          | number
          | symbol
          | string & {}

    Parameters

    • hook: THook

      The hook to handle

    • handler: HookHandler<THook, T>

      Function to execute when the hook is called

    Returns void

  • Register a one-time handler that removes itself after execution.

    Type Parameters

    • THook extends
          | string
          | number
          | symbol
          | string & {}

    Parameters

    • hook: THook

      The hook to handle once

    • handler: HookHandler<THook, T>

      Function to execute once when the hook is called

    Returns void