Firebase Tutorial on Firebase Detaching Callbacks

this chapter will show you how to detach callbacks in firebase.

detach callback for event type

let us say we want to detach a callback for a function with value event type.

example

var playersref = firebase.database().ref("players/");

ref.on("value", function(data) {
   console.log(data.val());
}, function (error) {
   console.log("error: " + error.code);
});

we need to use off() method. this will remove all callbacks with value event type.

playersref.off("value");

detach all callbacks

when we want to detach all callbacks, we can use −

playersref.off();