kinetex - v1.0.0-rc.1
    Preparing search index...

    Class HookRegistry

    Full-featured lifecycle hook registry supporting priority ordering, conditional execution, named hooks with ejection, and safe error isolation.

    Phases: beforeRequest → afterRequest → around → [dispatch] → beforeResponse → afterResponse Error phase: onError (can recover with synthetic response) Side-event phases: onRetry, onRedirect, onUploadProgress, onDownloadProgress, onCancel, onConnection

    Index

    Constructors

    Properties

    emitter: HookEmitter = ...

    Typed event emitter for pub/sub-style lifecycle events.

    Methods

    • Register a connection hook. Returns the hook ID for ejection.

      Parameters

      Returns string

    • Remove a hook by ID from all phases. Returns true if any hook was removed.

      Parameters

      • id: string

      Returns boolean

    • Check if a hook ID is registered in any phase.

      Parameters

      • id: string

      Returns boolean

    • Execute all on-retry hooks.

      Parameters

      • evt: RetryEvent
      • ctx: HookContext

      Returns Promise<void>

    • Execute all on-redirect hooks. Returns false if any hook returns false (redirect should not be followed).

      Parameters

      • evt: RedirectEvent
      • ctx: HookContext

      Returns Promise<boolean>

    • Execute all upload-progress hooks.

      Parameters

      • evt: ProgressEvent
      • ctx: HookContext

      Returns void

    • Execute all download-progress hooks.

      Parameters

      • evt: ProgressEvent
      • ctx: HookContext

      Returns void

    • Execute all on-cancel hooks.

      Parameters

      • evt: CancelEvent
      • ctx: HookContext

      Returns void

    • Execute all on-connection hooks.

      Parameters

      • evt: ConnectionEvent

      Returns void

    • Wrap a dispatch function with all registered around hooks. Around hooks form an onion: outermost (lowest priority) wraps innermost.

      Parameters

      Returns () => Promise<HookResponse>