Closed navaronbracke closed 2 years ago
Good idea!
I have added StoreRef.onCount()
method that should do what you ask for.. Dev version 3.3.0-dev.1
published.
It requires doing
dependencies:
sembast: >=3.3.0-dev.1`
in pubspec.yaml
That was quick, thank you! I'll bump my pubspec then :)
Currently we can get the
count
of aStoreRef
usingStoreRef.count(database)
. However this is a Future and there is no way to get a stream of changes for this value.I have tried using
return _storeRef.query().onSnapshots(_database).map((e) => e.length);
but that is a little cumbersome, and it gives extra updates where it is not needed (when existing records are updated we get events too).Ideally we should be able to do
final Stream<int> countStream = _storeRef.countStream();