listenTo method

  1. @override
StreamSubscription<DocumentModel?> listenTo(
  1. String documentId,
  2. DocumentChanged changed, {
  3. DocumentErrorHandler? errorHandler,
})
override

Implementation

@override
StreamSubscription<DocumentModel?> listenTo(
    String documentId, DocumentChanged changed,
    {DocumentErrorHandler? errorHandler}) {
  var stream =
      documentCollection.doc(documentId).snapshots().asyncMap((data) {
    return _populateDocPlus(data);
  });
  var theStream = stream.listen((value) {
    changed(value);
  });
  theStream.onError((theException, theStacktrace) {
    if (errorHandler != null) {
      errorHandler(theException, theStacktrace);
    }
  });
  return theStream;
}