onChange method
Create a Stream of changes to any of the specified tables.
Example to get the same effect as watch:
var subscription = db.onChange({'mytable'}).asyncMap((event) async {
  var data = await db.getAll('SELECT * FROM mytable');
  return data;
}).listen((data) {
  // Do something with the data here
});
This is preferred over watch when multiple queries need to be performed together when data is changed.
Implementation
Stream<UpdateNotification> onChange(Iterable<String>? tables,
    {Duration throttle = const Duration(milliseconds: 30),
    bool triggerImmediately = true}) {
  assert(updates != null,
      'updates stream must be provided to allow query watching');
  final filteredStream = tables != null
      ? updates!.transform(UpdateNotification.filterTablesTransformer(tables))
      : updates!;
  final throttledStream = UpdateNotification.throttleStream(
      filteredStream, throttle,
      addOne: triggerImmediately ? UpdateNotification.empty() : null);
  return throttledStream;
}