listenToDocument<T> method

StreamSubscription<DocumentSnapshot<Object?>> listenToDocument<T>(
  1. String collection,
  2. String documentId,
  3. String logReference, {
  4. required ValueSetter<DocumentSnapshot<Object?>> onDocumentChange,
})

Implementation

StreamSubscription<DocumentSnapshot> listenToDocument<T>(
  String collection,
  String documentId,
  String logReference, {
  required ValueSetter<DocumentSnapshot> onDocumentChange,
}) {
  final StreamSubscription<DocumentSnapshot> streamSubscription =
      _firebaseFirestore.collection(collection).doc(documentId).snapshots().listen((documentSnapshot) {
    _loggingService.log('FirestoreGenericService.listenToDocument.$logReference: New event.'
        ' Collection: $collection, DocId: $documentId');
    onDocumentChange(documentSnapshot);
  });

  return streamSubscription;
}