snapshots method
Returns an observable that emits the query results and updates whenever
the query results change unless subscribe=false
is provided.
Important: Make sure to unsubscribe from the observable when you are done with it.
Implementation
@override
Observable<Iterable<DocumentReference>> snapshots({bool subscribe = true}) {
if (_containsEmptyInCondition) {
return BehaviorSubject([]);
}
return _querySubscriptionManager
.processQuery(
build(), _collectionName, {}, {}, subscribe, _forceFetchFromServer)
.map((docs) => docs.map((docRecord) {
assert(docRecord.isNotEmpty);
final doc = docRecord[_collectionName] as Map<String, dynamic>;
final squidDocId = SquidDocIdObj(
collectionName: _collectionName,
docId: doc['__docId__'],
integrationId: _integrationId)
.toSquidDocId();
return _documentReferenceFactory.create(
squidDocId, _queryBuilderFactory);
}));
}