Skip to content

LSDE Dialog Engine / BlockHandler

Type Alias: BlockHandler<B, C> ​

BlockHandler<B, C> = (args) => CleanupFn | void

Defined in: types.ts:506

A block handler function. May return a cleanup function.

Type Parameters ​

B ​

B extends BlueprintBlock

C ​

C extends BaseBlockContext

Parameters ​

args ​

BlockHandlerArgs<B, C>

Returns ​

CleanupFn | void

Remarks ​

The handler is called when the engine dispatches a block of the matching type. It must call next() exactly once to advance the flow to the next block.

If the handler returns a function, it is stored as a cleanup function and called when the engine moves to the next block — use this to tear down UI, stop timers, etc.

Example ​

ts
engine.onDialog(({ block, next }) => {
  const el = showDialogUI(block);
  next();
  return () => el.remove(); // cleanup when leaving this block
});

See ​