-
Notifications
You must be signed in to change notification settings - Fork 930
value events not firing properly when offline #1314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I found a few problems with this issue:
|
This is a subtle but expected behavior. The Firebase Realtime Database SDK attempts never to raise 'value' events with partial data. In your example, push() will create a child underneath /todos, but since the SDK doesn't have the rest of the data for the /todos/ location, it can't raise a proper value event containing the entire /values/ location. If you were to add your 'value' listener and wait for an initial event (even if it's empty) before going offline, then the subsequent push() call would generate an event since the SDK has complete data for /todos/. In your case, you may find that listening to child_added, child_changed, and child_removed events will meet your needs better. If you had a 'child_added' listener instead of 'value', then it would fire for your push() call, even while offline, since we'd have complete data for the added child. Hope this helps. |
Mmmm yeah..well |
I get the point |
Thanks |
From docs: https://firebase.google.com/docs/database/web/read-and-write#listen_for_value_events
related with offline capabilities: #17
[REQUIRED] Describe the problem
Value events should fire when ever a change occurs within the whole path. This is supposed to work offline as well, and it does! but not in the same way:
Steps to reproduce:
for example:
listening for event values on root ("todos"):
ref('todos').on('value', f)
f
should be called when:ref('todos').push({ "text": "a" })
ref('todos').set(..)
however offline.
f
only gets called when change occur directly on the explicit updated spot.For example if I'm listening with:
ref('todos').on('value', f)
and I go offline case 2 works but case 1 does not.Relevant Code:
[REQUIRED] Describe your environment
The text was updated successfully, but these errors were encountered: