I have an application in which I want to load some amount of initial data (accomplished with Firebase.once('value')) and then at some point later I'd like to receive events of child nodes that have been added to that Firebase reference.
For this, I'd like to use Firebase.on('child_added'), but according to the definition (and seen in practice) it loads ALL of the data at that Firebase reference first.
Is there a way to get around this behavior and only listen for child_added events. Also, workarounds like dumping the initial set of data are not solutions (imagine a dataset with over a million data points - I don't want to have to every data point just to listen for when one gets added!).
EDIT: Firebase.on('child_added') can be combined with limit() to limit the amount of data that comes from the initial request. Likely for my application, only one data point will be added to the Firebase at a point in time so I've used Firebase.limit(1).on('child_added') which limits the amount of initial data loaded to a single data point. But, I don't like this workaround for two reasons:
- It's still a workaround. I'm still having to ignore data that I shouldn't have to worry about ignoring.
- If for some reason the nature of my application was to change and I was to add multiple children to the Firebase reference at one time - would imposing a
limit(1)limit the application from receiving all added children? I'm not sure if this is the case or ifchild_addedwould get called for each individual child added regardless if they were added as a batch.
It seems like providing a true/false flag as an argument to the call would be a nice solution, but I'll wait to see if there's an answer I've been glossing over...
startAtquery firebase.com/docs/ordered-data.html firebase.com/docs/javascript/query/startat.html - Prinzhorn