googlearchive / firebase-util

An experimental toolset for Firebase
http://firebase.github.io/firebase-util
MIT License
276 stars 58 forks source link

on('child_removed',...)'s snapshot does not contains the correct data #34

Closed AaronJPA closed 9 years ago

AaronJPA commented 9 years ago

on('child_removed',...)'s snapshot does not contains the correct data.

I'm opening four different issues because I'm not sure if they are related and, if they are not, they can be fixed separately. However, I used the same Plunker to simulate all of them, so it is a little bigger than usual. I tried to explain everything in the comments, but if something is not clear enough, just let me know.

http://plnkr.co/edit/Y0mp2XDtSQ0Pz9ClXctZ

katowulf commented 9 years ago

Thanks for the great repro! This is a well documented bug(s) and greatly appreciated.

katowulf commented 9 years ago

It doesn't look like we can improve on this much. If the secondary path is deleted before the master, then this is just an update of the data--there's no real way to capture the intent until all the paths are gone. Attempting to defer the remove() operation until all paths return gets very complicated and tricky very quickly and potentially creates ordering issues.

It looks like the local remove could return an entire value with some trickiness and complexity, coupled with a good deal of refactoring, but the only consistent answer here would be to always return null as a value. Neither exactly match the API and we won't get any closer.