watch method
Stream<List<TRow> >
watch({
- MssqlWatchStrategy strategy = MssqlWatchStrategy.localWrites,
- Duration interval = const Duration(seconds: 1),
- Iterable<
String> ? tables,
Re-runs this query when its tables may have changed.
MssqlWatchStrategy.localWrites sees committed writes on this AppDatabase family only. MssqlWatchStrategy.polling also sees external writers. There is no CDC / change-tracking push.
Implementation
Stream<List<TRow>> watch({
MssqlWatchStrategy strategy = MssqlWatchStrategy.localWrites,
Duration interval = const Duration(seconds: 1),
Iterable<String>? tables,
}) {
final watched = <String>{
...(tables ?? <String>[binding.qualifiedName]),
};
if (watched.isEmpty) {
throw ArgumentError.value(
tables,
'tables',
'watch() needs at least one table name when the query cannot '
'infer dependencies.',
);
}
return mssqlWatchRows<TRow>(
strategy: strategy,
interval: interval,
tables: watched,
hub: context.changes,
read: get,
same: (a, b) => mssqlRowsEqual(a, b, binding.toColumns),
);
}