Samuel Uyemura Samuel Uyemura - 6 months ago 33
Javascript Question

Check for completion on the firebase js .forEach method?

I know that there's a completion handler for

, but I was wondering if there was something like that for

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
method is done running.

P.S. My function is actually stated in another file, but I just call it normally.

Answer Source

No, it is a synchronous javascript function. Simply add a line after the function.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download