in this chapter, we will show you how to handle the firebase connection state.
check connection
we can check for connection value using the following code.
index.js
var connectedref = firebase.database().ref(".info/connected");
connectedref.on("value", function(snap) {
if (snap.val() === true) {
alert("connected");
} else {
alert("not connected");
}
});
when we run the app, the pop up will inform us about the connection.
by using the above given function, you can keep a track of the connection state and update your app accordingly.