withTxHooks

Function

Signature

function withTxHooks<T>(cb): T;

core/src/tx-hooks/tx-hooks.ts:284

Execute a callback with auto-managed tx hooks. Flushes on success, discards on error.

Wrap the transaction from outside, so the hooks flush after COMMIT. A state provider without transaction events of its own calls it in withTransaction; open your own transaction inside it and pass txHooks in the transaction context.

When cb returns a promise, withTxHooks returns a promise that settles after the commit callbacks. When cb returns a plain value, as a driver's own synchronous transaction does, the commit callbacks run synchronously and withTxHooks returns the value; a commit callback that returns a promise then makes it throw after every callback has run.

Type Parameters

  • T

Parameters

  • cb
    (txHooks) => T

Returns

T

Used in guides

esc

Search guides, integrations and every exported symbol.

↑ ↓ to navigate↵ to open