streamCollection method

Stream<List<Document>> streamCollection(
  1. String path
)

Implementation

Stream<List<Document>> streamCollection(String path) {
  if (_listenRequestStreamMap.containsKey(path)) {
    return _mapCollectionStream(_listenRequestStreamMap[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;

  final listenRequestStream = _FirestoreGatewayStreamCache(
      onDone: _handleDone, userInfo: path, onError: _handleError);
  _listenRequestStreamMap[path] = listenRequestStream;

  listenRequestStream.setListenRequest(request, _client, database);

  return _mapCollectionStream(listenRequestStream);
}