public IListenerRegistration AddSnapshotListener(bool includeMetadataChanges, DocumentSnapshotHandler listener) { var registration = _documentReference.AddSnapshotListener(includeMetadataChanges ? MetadataChanges.Include : MetadataChanges.Exclude, new EventHandlerListener <DocumentSnapshot>((value, error) => { listener?.Invoke(value == null ? null : new DocumentSnapshotWrapper(value), error == null ? null : ExceptionMapper.Map(error)); })); return(new ListenerRegistrationWrapper(registration)); }
public IListenerRegistration AddSnapshotListener(DocumentSnapshotHandler listener) { var registration = _documentReference.AddSnapshotListener(new EventHandlerListener <DocumentSnapshot>((value, error) => { listener?.Invoke(value == null ? null : new DocumentSnapshotWrapper(value), error == null ? null : ExceptionMapper.Map(error)); })); return(new ListenerRegistrationWrapper(registration)); }
public void GetDocument(DocumentSnapshotHandler handler) { var tcs = new TaskCompletionSource <IDocumentSnapshot>(); DocumentReference.Get().AddOnCompleteListener(new OnCompleteHandlerListener((task) => { var snapshot = !task.IsSuccessful ? null : task.Result.JavaCast <DocumentSnapshot>(); handler?.Invoke(snapshot == null ? null : new DocumentSnapshotWrapper(snapshot), task.IsSuccessful ? null : new CloudFirestoreException(task.Exception.Message)); })); }
public void GetDocument(Source source, DocumentSnapshotHandler handler) { var tcs = new TaskCompletionSource <IDocumentSnapshot>(); _documentReference.Get(source.ToNative()).AddOnCompleteListener(new OnCompleteHandlerListener((task) => { var snapshot = !task.IsSuccessful ? null : task.Result.JavaCast <DocumentSnapshot>(); handler?.Invoke(snapshot == null ? null : new DocumentSnapshotWrapper(snapshot), task.IsSuccessful ? null : ExceptionMapper.Map(task.Exception)); })); }
public IListenerRegistration AddSnapshotListener(bool includeMetadataChanges, DocumentSnapshotHandler listener) { if (!includeMetadataChanges) { return(AddSnapshotListener(listener)); } var option = new DocumentListenOptions().IncludeMetadataChanges(); var registration = DocumentReference.AddSnapshotListener(option, new EventHandlerListener <DocumentSnapshot>((value, error) => { listener?.Invoke(value == null ? null : new DocumentSnapshotWrapper(value), error == null ? null : new CloudFirestoreException(error.Message)); })); return(new ListenerRegistrationWrapper(registration)); }