Search code examples
iosfirebasefirebase-realtime-databaseobservers

Observing Firebase nodes before they exist


Lets say I want current user to observe when theres a childAdded to the friendRequest node so they can see if they are the recipient. If there are zero friend requests, when observer is called from client, will observer still be listening when a friend request comes through at a later time? If not, does this mean I need to have some arbitrary placeholder value to assure the node exists, when client attempts to observe?


Solution

  • You can most definitely observe/listen to a location that has no data. Your observer/listener will still be called when data arrives there.

    This is behavior you can pretty easily test for yourself by writing the observer code in your app, and making a quick change in the Firebase Realtime Database console that would trigger your observer.