watch method Null safety

  1. @override
Stream<List<TypedResult>> watch()
override

Creates an auto-updating stream of the result that emits new items whenever any table used in this statement changes.

Implementation

@override
Stream<List<TypedResult>> watch() {
  final ctx = constructQuery();
  final fetcher = QueryStreamFetcher(
    readsFrom: TableUpdateQuery.onAllTables(ctx.watchedTables),
    fetchData: () => _getRaw(ctx),
    key: StreamKey(ctx.sql, ctx.boundVariables),
  );

  return database
      .createStream(fetcher)
      .asyncMap((rows) => _mapResponse(ctx, rows));
}