public void ObserveSingle <T>(FirebaseEventDelegate <T> handler)
        {
            var rootNode = databaseReference;

            rootNode.ObserveSingleEvent(DataEventType.Value, (snapshot) =>
            {
                if (snapshot.Exists)
                {
                    FirebaseXamarinHelper.RunOnUIThread(() =>
                    {
                        var data     = snapshot.GetValue();
                        var snapData = DataConverter.Convert <T>(data, GetObjectFromHandler(handler));
                        SetObjectFromHandler(handler, snapData);
                        handler.OnSnapshot(snapData);
                    });
                }
                else
                {
                    handler?.OnError?.Invoke(new SnapshotNotFoundException());
                }
            }, (error) =>
            {
                handler?.OnError?.Invoke(new FirebaseException(error));
            });
        }
        public object Observe<T>(FirebaseEventDelegate<T> handler)
        {
            var listener = new TypeValueListener<T>(handler);

            query.AddValueEventListener(listener);
            return listener;
        }
Exemplo n.º 3
0
 public TypeValueListener(FirebaseEventDelegate <T> eventDelegate)
 {
     this.eventDelegate = eventDelegate;
 }
 public StringValueListener(FirebaseEventDelegate eventDelegate)
 {
     this.eventDelegate = eventDelegate;
 }
Exemplo n.º 5
0
 public void ObserveSingle <T>(string path, FirebaseEventDelegate <T> handler)
 {
     GetChild(path).ObserveSingle <T>(handler);
 }
Exemplo n.º 6
0
 public object Observe <T>(string path, FirebaseEventDelegate <T> handler)
 {
     return(GetChild(path).Observe <T>(handler));
 }
 public void ObserveSingle<T>(FirebaseEventDelegate<T> handler)
 {
     query.AddListenerForSingleValueEvent(new TypeValueListener<T>(handler));
 }