Reputation: 27
I know that there's a completion handler for .set
and .update
, but I was wondering if there was something like that for .forEach
.
For example, something like this:
firebase.database().ref().child('kid').orderByChild('date').on('value', function(snapshot) {
snapshot.forEach(function(kid) {
}, function(error) { //This is where the error is thrown
}
});
If this isn't possible, is there a workaround? I just need a function to call once the .forEach
method is done running.
P.S. My function is actually stated in another file, but I just call it normally.
Upvotes: 0
Views: 174
Reputation: 2478
No, it is a synchronous javascript function. Simply add a line after the function.
Upvotes: 1