When turning on persistence for Firebase in iOS what actually happens to my observers and how they behave on a technical level?
I have a good idea how it should work on a high-level based on this https://www.firebase.com/docs/ios/guide/offline-capabilities.html - Firebase essentially keeps a cached copy of the data you can access whilst offline.
What I don't understand is how many times my observers should fire and with what information.
It's actually pretty simple. When you attach an observer (whether using
observeSingleEventOfType), Firebase will:
There are a couple subtleties that fall out of this though:
ChildAddedevents for complete children (e.g. /foo/bar), but you won't get a
Valueevent (e.g. for /foo) until we've gotten complete data from the server for the location you're observing.
observeSingleEventOfType, you're explicitly asking for only a single event and so if you have cached data, #1 will happen but #2 will not, which may not be what you want (you'll never see the latest server data).
Hope this helps!