Closed erickvrech89 closed 2 years ago
I had the same problem few months back. After searching Internet I got a fix.
we have to create a IDisposable variable out of subscribe function like this
IDisposable Subscriber = _shopDb.AsObservable().Subscribe(item => Console.WriteLine($"Firebase Subscribe: {item.EventType} {item.EventSource}"));
now Whenever you need to close your application or do anything which needs to destroy the object, just dispose this "Subscriber" Object.
Subscriber.Dispose();
and you are good to go.
Actually the problem is that we have to properly Detach listeners which is listening to the node at Realtime. you can find more details from this page https://firebase.google.com/docs/database/web/lists-of-data#detach_listeners
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Closing the issue due to inactivity. Feel free to re-open
I'm using Xamarin.Forms, I have a singleton 'service' and in the contructor I connect using the code below and await the subscribe event.
However, when connecting normally, I go to the firebase portal and manually add one or two items, the application normally receives the inserted items, if I change both items manually through the portal, the application continues to receive updates, however if I disconnect and connect the device's internet or restarting the app, I don't get any more updates, just new items inserted, if I change the old items I don't get it but if I change the new one I normally receive it, however, if I restart the internet or the app again problem happens with the new item and I never get updates from it again, but everyone is offline but with the last value received by the 'subscribe' before I restart the internet of the device or the app.
Using the parameter 'StreamingOptions.Everything' the problem does not occur when reconnecting the internet or restarting the app, but I don't want to use it because I get the items from the online collection every time I reopen the app even though I am already offline correctly, consuming the bandwidth download of the paid plan immensely of Firebase.
From what I tested locally, the parameter 'StreamingOptions.LatestOnly' is also working correctly until you restart the app or reconnect the device's internet, so I'm in doubt if there are any bugs or optimization to be done in the library.
I hope I have summarized it well, and sorry for the bad English
Thnaks.