I'm using the Objective-C API, though I would imagine that this question is valid regardless of language.
I'm trying to write my code so that my app observes when child objects are removed from a particular node. When a child object is removed, I make local changes so that the local version of that child object is deleted.
I also have observers set for each child object's children on Firebase. This is so that I can propagate changes to those values locally as soon as they are made.
My observers are (finally!) working just fine – except that when I delete an object from Firebase, it seems like the observers for the object's children are triggered before the observer for the object's parent. E.g.,
If I have several blog posts listed under $userId/blogs/
according to their $blogId
, and if each blog post has properties such as name
and text
, it seems like the FEventTypeValue
observers at $userId/blogs/$blogId/name
and $userId/blogs/$blogId/text
are triggered before the FEventTypeChildRemoved
observer at $userId/blogs
when I set a particular $blogId
to nil.
Any idea how I can set it so that the FEventTypeChildRemoved
observer triggers before the FEventTypeValue
observers? The alternative would be to always check whether the parent object exists when observing a change to a property on Firebase, but this to me seems like overkill.