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 IListenerRegistration AddSnapshotListener(DocumentSnapshotHandler listener) { var registration = _documentReference.AddSnapshotListener((snapshot, error) => { listener?.Invoke(snapshot == null ? null : new DocumentSnapshotWrapper(snapshot), error == null ? null : ExceptionMapper.Map(error)); }); return(new ListenerRegistrationWrapper(registration)); }
public static Task <T> GetDocumentAsync <T>(this DocumentReference reference) where T : class { var tcs = new TaskCompletionSource <T>(); reference .AddSnapshotListener((snapshot, error) => { if (error != null) { tcs.SetException(new Exception(error.LocalizedDescription)); return; } tcs.SetResult(Cast <T>(snapshot)); }); return(tcs.Task); }