我正在阅读关于onDisconnect
的firebase文档,但它没有提及我正在寻找的操作。 https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnectFirebase onDisconnect如何触发其他功能
目标:当连接断开时,我想运行一个函数来更新与此连接数据无关的其他数据。
我的代码如下:
let PlayerRef = database.ref("/players");
let MessageRef = database.ref("/messages");
let con=playersRef.child(0).push('test');
con.onDisconnect().remove(); // yes i want to remove that current connection
// BUT I also want to update the MessageRef that is
//using the data in the "con", how can I acheive this???
我将如何实现这一目标?
我真的不明白这一点。我尝试更新的数据不会附加到'.onDisconnect()'函数。基本上我有locA.onDisconnect()。wantToUpdate(locB) – WABBIT0111
'onDisconnect'可以连接到任何位置,所以'locB.onDisconnect().set(...)' –
这样一般来说。 '.onDisconnect()'不知道什么已经断开,除了检测到某些东西已经断开连接? – WABBIT0111