Skip to content Skip to sidebar Skip to footer

Firebase Setpersistenceenabled(true) What About The Downloaded Data

here is my function to get data : public void retrievedata(){ FirstRef.child(obj.getsEventID()).orderByChild('date').addChildEventListener(new ChildEventListener() { @O

Solution 1:

When you attach a listener for data that is already present on the device, Firebase immediately satisfies the listener with the data that it has on the device.

So the Firebase client will immediately call your onChildAdded with the 10 child nodes that we persisted earlier.

It then sends a request to the server to get the most up to date version. It does this with a so-called delta-sync, meaning that it by sending a hash value of the local state, which the server compares to the current state in the database. The server then sends the delta back, which the Firebase client then uses to update its internal snapshot and the state on disk.

If there are any changes, the Firebase client then fires the correct local events to allow your application to update to the new state. So in the case where two child nodes were added, it will call onChildAdded for each of those.

If you were to use a listener with a limit, say limitToLast(10), then the Firebase client would also call onChildRemoved for the two children that are no longer within that query (since they were pushed out by the new children).

Solution 2:

The previously cached 10 children will be loaded from disk and not transferred from the server again.

Post a Comment for "Firebase Setpersistenceenabled(true) What About The Downloaded Data"