Prism API
    Preparing search index...

    Class Hooks

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Adds the given callback to the list of callbacks for the given hook and returns a function that removes the hook again when called.

      The callback will be invoked when the hook it is registered for is run. Hooks are usually directly run by a highlight function but you can also run hooks yourself.

      One callback function can be registered to multiple hooks.

      A callback function must not be registered for the same hook multiple times. Doing so will cause undefined behavior. However, registering a callback again after removing it is fine.

      Type Parameters

      • Name extends string

      Parameters

      • name: Name

        The name of the hook.

      • callback: HookCallback<Name>

        The callback function which is given environment variables.

      Returns () => void

    • Runs a hook invoking all registered callbacks with the given environment variables.

      Callbacks will be invoked synchronously and in the order in which they were registered.

      Type Parameters

      • Name extends string

      Parameters

      • name: Name

        The name of the hook.

      • env: HookEnv<Name>

        The environment variables of the hook passed to all callbacks registered.

      Returns void