Skip to main content

hook

const

Declares that this mod wants to step in front of a host action. Interception is two halves. This half is the declaration: which action, under what name, gated by what condition. It is what the manifest records and what the user grants permission for. The other half is the interceptor itself, registered at runtime with `ctx.hooks.beforeAction(action, interceptor)` from inside an `effect`. Declaring here without registering there means nothing runs. A hook fires before the action does and can change its input, let it through, or stop it. That is what separates it from `system.on` and `ctx.on`, which observe after the fact and cannot alter anything.

const hook: Readonly<{ beforeAction: <TAction extends string>(input: BeforeActionHookInput<TAction>) => BeforeActionHook<NormalizeHostActionReference<TAction>> }>

Import

import { hook } from '@modular/sdk';

Notes

category
Authoring