watch method
Returns a Stream that emits results of sql whenever tables change.
The stream automatically re-queries the database after any execute call
that touches one of the watched tables.
Implementation
Stream watch(String sql,
{List<Object?> params = const [],
FromMap? fromMap,
bool singleResult = false,
required List<String> tables,
String? dbName}) {
final StreamController sc = StreamController();
final StreamInfo streamInfo = StreamInfo(
controller: sc,
sql: sql,
tables: tables,
params: params,
fromMap: fromMap,
dbName: dbName ?? defaultDBName,
singleResult: singleResult);
streams.add(streamInfo);
_updateStream(streamInfo);
sc.done.then((value) => streams.remove(streamInfo));
return sc.stream;
}