tableUpdates method Null safety

Stream<Set<TableUpdate>> tableUpdates(
  1. [TableUpdateQuery query = const TableUpdateQuery.any()]
)

Listen for table updates reported through notifyUpdates.

By default, this listens to every table update. Table updates are reported as a set of individual updates that happened atomically. An optional filter can be provided in the query parameter. When set, only updates matching the query will be reported in the stream.

When called inside a transaction, the stream will close when the transaction completes or is rolled back. Otherwise, the stream will complete as the database is closed.

Implementation

Stream<Set<TableUpdate>> tableUpdates(
    [TableUpdateQuery query = const TableUpdateQuery.any()]) {
  // The stream should refer to the transaction active when tableUpdates was
  // called, not the one when a listener attaches.
  final engine = resolvedEngine;

  // We're wrapping updatesForSync in a stream controller to make it async.
  return Stream.multi(
    (controller) {
      final source = engine.streamQueries.updatesForSync(query);
      source.pipe(controller);
    },
    isBroadcast: true,
  );
}