@tanstack/db
Version:
A reactive client store for building super fast apps on sync
11 lines (9 loc) • 373 B
text/typescript
import type { Transaction } from '../transactions'
/** Wait for the handler even when a rolled-back receipt settles early. */
export function runWithCommitCompletion<T extends object>(
run: () => Transaction<T>,
onCommit?: () => Promise<unknown> | undefined,
): Promise<unknown> {
const transaction = run()
return onCommit?.() ?? transaction.isPersisted.promise
}