listenToDocument<T> method
StreamSubscription<DocumentSnapshot<Object?> >
listenToDocument<T>(
- String collection,
- String documentId,
- String logReference, {
- required ValueSetter<
DocumentSnapshot< onDocumentChange,Object?> >
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;
}