Sam Uyemura
Sam Uyemura

Reputation: 27

Check for completion on the firebase js .forEach method?

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

Answers (1)

richie
richie

Reputation: 2478

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

Upvotes: 1

Related Questions