step-up-labs / firebase-database-dotnet

C# library for Firebase Realtime Database.
MIT License
668 stars 168 forks source link

Observer won't detect Change #295

Open RPGFabi opened 1 year ago

RPGFabi commented 1 year ago

Currently I try an Observer to get me updates from my DB, which looks like this:

root ---schoolData ------name ------etc.

I have an Class, which defines the Schooldata and I can read and store it.

When I try to add an Observer with this code

    void Test(){
        var observable = firebase.Child("schoolData").AsObservable<SchoolData>().Subscribe(data => Test2(data));
        Debug.Log("Created");
    }

    private void Test2(FirebaseEvent<SchoolData> obj)
    {
        Debug.Log(obj.Object);
    }`

I get an message, that it is created, but when I change an child's value or add an child, the Test2 function wont trigger.

What am I doing wrong?

Edit: Capturing and printing an exception in AsObservable() shows, states this:

Exception occured while processing the request. Url: databaseurl/schoolData/.json Request Data: Response: data: {correct Data} UnityEngine.Debug:Log (object) Firebase.Firebasehandler:Test3 (object,Firebase.Database.ContinueExceptionEventArgs1<Firebase.Database.FirebaseException>) (at Assets/Scripts/Firebase/Firebasehandler.cs:277) Firebase.Database.Streaming.FirebaseSubscription1:OnExceptionThrown (Firebase.Database.FirebaseException,bool) Firebase.Database.Streaming.FirebaseSubscription`1/d__14:MoveNext () System.Threading._ThreadPoolWaitCallback:PerformWaitCallback ()

So it reads the correct data and detects the change in data true having 2 different data requested but it wont call the Action i passed as an argument.

Even listening to an specific child (name) doesnt register an change