HookRegistry class

Global singleton registry for all hooks.

Manages hook registration, dispatch, and lifecycle. All UseCases automatically dispatch to registered hooks — no per-UseCase configuration needed.

Usage

// Register hooks (typically in main())
HookRegistry.instance.register(EngagementTrackingHook());
HookRegistry.instance.register(TelemetryHook());

// Hooks now fire automatically on every UseCase execution.

Disabling

Set isEnabled to false to instantly disable all hooks (e.g., GDPR opt-out, debug mode):

HookRegistry.instance.isEnabled = false;

Properties

hashCode → int
The hash code for this object.
no setterinherited
hooks → List<Hook>
All registered hooks, sorted by priority (ascending — lower first).
no setter
isEmpty → bool
Whether any hooks are registered.
no setter
isEnabled ↔ bool
Whether hooks are globally enabled.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() → void
Unregister all hooks.
dispatch(HookContext context, HookPhase phase) → void
Dispatch a context + phase to all matching hooks.
dispatchAwaited(HookContext context, HookPhase phase) → Future<void>
Dispatch a context + phase to all matching hooks, awaiting every blocking hook (Hook.blocking) to completion before returning.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
register(Hook hook) → void
Register a hook.
toString() → String
A string representation of this object.
inherited
unregister(String id) → void
Unregister a hook by ID.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

instance → HookRegistry
final