WAB*_*111 3 javascript firebase firebase-realtime-database
我正在阅读firebase文档,onDisconnect但并没有提及我要寻找的操作。
https://firebase.google.com/docs/reference/js/firebase.database.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???
Run Code Online (Sandbox Code Playgroud)
我将如何实现?
您可以将onDisconnect()处理程序附加到数据库中的任何位置,然后将数据删除或写入该位置。
但是,onDisconnect()可以通过将写入操作提前发送到Firebase服务器来实现。因此,您可以编写任何值,只要在附加onDisconnect侦听器时可以在客户端上计算该值即可。
| 归档时间: |
|
| 查看次数: |
2968 次 |
| 最近记录: |