registerCommitHook method

void registerCommitHook(
  1. int callback()
)

register a commit hook, it invoke when a commit occurred.

Note: the commit hook only trigger for the current connection. A commit from another connection will not trigger the callback.

Implementation

void registerCommitHook(int Function() callback) {
  _hookKey ??= [null, null, null];
  _hookKey![0] ??= sqlite.malloc<sqlite.Int32>(4);
  final key = _hookKey![0]!;
  _callbackHooks ??= [null, null, null];
  _callbackHooks![0] ??= <sqlite.Pointer, int Function()>{};
  _callbackHooks![0]![key] = callback;
  final ptr = sqlite.Pointer.fromFunction<sqlite.DefxSize>(_commitHookCallback, sqlite.FAIL);
  Driver.binder.commit_hook(_db!, ptr, key.cast());
}