registerUpdateHook method

void registerUpdateHook(
  1. UpdateHook callback
)

register a update hook, it invoke when an update occurred.

Note: the update hook only trigger for the current connection. An update from another connection will not trigger the callback.

Implementation

void registerUpdateHook(UpdateHook callback) {
  _hookKey ??= [null, null, null];
  _hookKey![2] ??= sqlite.malloc<sqlite.Int8>();
  final key = _hookKey![2]!;
  _callbackHooks ??= [null, null, null];
  _callbackHooks![2] ??= <sqlite.Pointer, UpdateHook>{};
  _callbackHooks![2]![key] = callback;
  final ptr = sqlite.Pointer.fromFunction<sqlite.DefDefTypeGen10>(_updateHookCallback);
  Driver.binder.update_hook(_db!, ptr, key.cast());
}