Skip to content Skip to sidebar Skip to footer

Firebase Realtime Database: Does 'value' Event Fires Automatically

As I understand, when this following line of code is interpreted/executed by Javascript ref.on('value',callback) (similar to document.addEventListener('click', callback)). The c

Solution 1:

According to the documentation:

You can use the value event to read a static snapshot of the contents at a given path, as they existed at the time of the event. This method is triggered once when the listener is attached and again every time the data, including children, changes. The event callback is passed a snapshot containing all data at that location, including child data. If there is no data, the snapshot will return false when you call exists() and null when you call val() on it.

When you attach a listener, the SDK will use its persistent connection to the database to check if there is new data. If there is not any new data, then the locally cached data is provided.

Post a Comment for "Firebase Realtime Database: Does 'value' Event Fires Automatically"