简体   繁体   中英

Firebase get if user is connected while calling db

Is there a way of getting if the user is connected/disconnect while reading data from database? I know there's .onDisconnect and database().ref('./info/connected') but what i want to know is if there's something more like this:

firebase.database().ref('/someURL').once('value').then(snap => {
  //READ DATA
}, err => {
  //GET THE DISCONNECT HERE
}).catch(err => {
  //OR GET HERE
});

Looking on the docs i wasn't able to find a error code for disconnection.

Thanks in advance.

Nope, that type of callback doesn't exist.

When you attach a listener to a location while the device is not connected to the back-end, one of two things can happen:

  1. the data is available in memory already, in which case your callback will be fired with this data.
  2. the data is not available in memory, in which case the callback won't fire.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM