dimanche 1 février 2015

Use off() directly in on() callback Firebase?


Let's say I have a one and done operation. Like deletes.



var q = ref.child('users').child(targetUserId).child('chat');
q.on('child_added', function(obj) {
obj.ref().remove();

//This works right?
q.off();
});


Can I execute off() directly in the on() callback? I don't need to specify eventType correct?


Nothing else to clean up right?


From the docs:

Similarly, if no eventType or callback is specified, all callbacks for the reference will be removed.





Aucun commentaire:

Enregistrer un commentaire