I want it to wait until .update() is done before going to the next player in the otherPlayers array. I didn't know if generators or something else could work here.
let {players} = this.props;
for(let player of otherPlayers) {
const index = players.findIndex(p => p.Id === player.Id);
const firebaseId = index && players[index].firebaseId;
if(index !== -1 && firebaseId !== null) {
window.firebase.database().ref(`/players/${firebaseId}`)
.update({...player}, /* Callback possible */);
}
}