Developer

Hooks

Three primitives for applet-to-applet communication: actions, filters, and calls.

Hooks

Hooks let applets communicate with each other safely. Three primitives:

PrimitiveUse whenPattern
ActionsBroadcasting eventsFire-and-forget, multiple listeners
FiltersTransforming data through handlersPriority chain, each handler mutates
CallsTyped request/response operationsOne handler, one reply

Most applets use a mix. Use actions for notifications (“weather data updated”), filters for transforms (“format this temperature”), and calls for structured operations (“open this doc in the editor, return the opened path”).

Which one to pick?

  • Does the caller need a reply?

    • Yes, and the semantics are “invoke this specific operation”: calls.
    • Yes, and the semantics are “pipe this value through everything listening”: filters.
    • No: actions.
  • Is there exactly one sensible handler (e.g., “get the currently opened file”)?

    • Yes: calls.
  • Can there be many listeners that all want to know about an event?

    • Yes: actions.

Capabilities

CapabilityGrants
hooks:provideRegister action listeners, filter handlers, or call-hook handlers
hooks:consumeFire actions, apply filters, invoke calls

Most applets that use hooks need both.