firebase-database-dotnet icon indicating copy to clipboard operation
firebase-database-dotnet copied to clipboard

Subscription breaks after Firebase.Database.Streaming.FirebaseEventType.Delete

Open quibenefacit opened this issue 3 years ago • 2 comments

This problems occurs in version 4.0.7. I haven't tried it with any other versions. Xamarin.Forms version is 5.0.0.229.

I have the following subscription:

firebaseClient.Child("Products")
     .AsObservable<Prod>()
     .Where(item => (item.Object.uid == _thisUid)
     .Subscribe(obs => {
         switch(obs.EventType) {
                case Firebase.Database.Streaming.FirebaseEventType.InsertOrUpdate:
                            var m = obs.Object;
                                prodlist.Add(new Prod() {
                                    Name = m.uniquename,
                                });
                            }
                break;
                case Firebase.Database.Streaming.FirebaseEventType.Delete:
                            var m2 = obs.Object;
                            foreach (var p in prodlist) {
                                if(p.uniquename== m2.uniquename) prodlist.Remove(t);
                            } 
                break;
         }
         PropertyChanged(this, new PropertyChangedEventArgs(nameof(prodlist)));
    }

Any number of actions of type Firebase.Database.Streaming.FirebaseEventType.InsertOrUpdate work fine until the first action Firebase.Database.Streaming.FirebaseEventType.Delete. After the latter gets processed, no subsequent subscription events get fired.

quibenefacit avatar Jan 24 '22 21:01 quibenefacit

Hi,

Did you ever make any progress on this? I'm facing the same issue

danieljustus32 avatar Mar 01 '22 04:03 danieljustus32

you can reply this method, with the Subscribe function https://github.com/step-up-labs/firebase-database-dotnet/issues/162#issuecomment-473751834

TathataHY avatar Feb 11 '23 18:02 TathataHY