Skip to content

HookOptions

The options that every hook of ctx.hooks accepts. They state for which changes the app calls the hook, and what happens when the hook itself fails.

// Called for every deletion of a row. The deletion is refused if the hook fails.
ctx.hooks.shouldDelete({ on: 'row', onTimeout: 'veto' }, hook);
// Called only for the deletion of rows and of outlines.
ctx.hooks.shouldDelete({ topics: ['row.delete', 'outline.delete'] }, hook);
readonly on?: string;

A kind of thing: row, outline, area or search. The hook receives every topic that concerns this kind of thing.


readonly onTimeout?: "allow" | "veto";

What happens when the hook throws an error or takes too long: allow lets the change go through, and veto refuses it. The default is allow.


readonly topics?: readonly string[];

The topics that the hook listens to, for example row.delete, row.* or *. A topic names a kind of change to a kind of thing. When neither topics nor on is given, the hook receives every topic (*).