Skip to content

Type Alias: ConfirmHandler

API / @xmachines/play-dom / ConfirmHandler

type ConfirmHandler = (confirm, action) => boolean | Promise<boolean>;

Defined in: @xmachines/json-render-dom

Hook consulted before executing an action binding that declares confirm.

With this hook, the host owns the confirmation flow — window.confirm, a custom dialog, or a test stub: return (or resolve) true to execute the action, false to skip it.

Without it, the renderer works as the framework renderers do: the binding waits as the pending confirmation of the tree, which a component reads and answers through ctx.confirmation, and the default confirm dialog shows it (createConfirmDialog; turn it off with the confirmDialog: false option). A cancel runs nothing and throws nothing.

Parameters

ParameterTypeDescription
confirmActionConfirmThe confirm config from the spec, with title and message already ${path}-interpolated against the store.
actionResolvedActionThe fully resolved action (name, params, chain handlers).

Returns

boolean | Promise<boolean>

true (or a promise of true) to execute the action; anything falsy to skip it silently.

Example

renderSpec(spec, store, registry, {
onConfirm: (confirm) => window.confirm(`${confirm.title}\n${confirm.message}`),
});