streamCollection method
Implementation
Stream<List<Document>> streamCollection(String path) {
if (_listenStreamCache.containsKey(path)) {
return _mapCollectionStream(_listenStreamCache[path]!);
}
var selector = StructuredQuery_CollectionSelector()
..collectionId = path.substring(path.lastIndexOf('/') + 1);
var query = StructuredQuery()..from.add(selector);
final queryTarget = Target_QueryTarget()
..parent = path.substring(0, path.lastIndexOf('/'))
..structuredQuery = query;
final target = Target()..query = queryTarget;
final request = ListenRequest()
..database = database
..addTarget = target;
_listenStreamCache[path] = _ListenStreamWrapper.create(
request,
(requestStream) => _client.listen(requestStream,
options: CallOptions(
metadata: {'google-cloud-resource-prefix': database})),
onDone: () => _listenStreamCache.remove(path));
return _mapCollectionStream(_listenStreamCache[path]!);
}