Skip to content

HookRegistry

Defined in: src/hooks/registry.ts:31

Implementation of the hook registry for managing hook callbacks. Maintains mappings between event types and callback functions.

  • HookRegistry
new HookRegistry(): HookRegistryImplementation;

Defined in: src/hooks/registry.ts:34

HookRegistryImplementation

addCallback<T>(eventType, callback): HookCleanup;

Defined in: src/hooks/registry.ts:45

Register a callback function for a specific event type.

Type Parameter
T extends HookableEvent
ParameterTypeDescription
eventTypeHookableEventConstructor<T>The event class constructor to register the callback for
callbackHookCallback<T>The callback function to invoke when the event occurs

HookCleanup

Cleanup function that removes the callback when invoked

HookRegistry.addCallback

invokeCallbacks<T>(event): Promise<T>;

Defined in: src/hooks/registry.ts:72

Invoke all registered callbacks for the given event. Awaits each callback, supporting both sync and async.

InterruptErrors are collected across callbacks rather than immediately thrown, allowing all hooks to register their interrupts. Non-interrupt errors propagate immediately.

Type Parameter
T extends HookableEvent
ParameterTypeDescription
eventTThe event to invoke callbacks for

Promise<T>

The event after all callbacks have been invoked

InterruptError with all collected interrupts after all callbacks complete