rlamasb / Firebase.Xamarin

Light weight wrapper for Firebase Realtime Database REST API.
MIT License
149 stars 39 forks source link

Observer subscription not working #26

Open KevinSchuddinck opened 7 years ago

KevinSchuddinck commented 7 years ago

I have a problem with the observer subscription of my firebase database. I subscribe my Listview to the realtime database of firebase with the following lines of code. I request the firebaseclient to give me an observer of the database, which I then ask to listen to any changes made in the database. If there are changes do the following.

Observer = firebase.Child("users").AsObservable<Account>();
List<Account> accountsFromDB = new List<Account>();
Observer.Subscribe(next => 
                    { 
                        accountsFromDB.Add(account.Object); 
                    }, 
                error => { Debug.WriteLine("error"); }, 
                onCompleted => 
                    { 
                        adapter.setData(accountsFromDB);
                        adapter.NotifyDataSetChanged(); 
                    }
                );

So when a change happens in the database the "next" will fetch every item in the database and add to the list, this works fine. After everything is collected from the database the "error" or "onCompleted" action should be called but aren't. Can someone help me understand this issue?