已关闭,此问题需要details or clarity。目前不接受答复。
**想改善这个问题吗?**通过editing this post添加详细信息并澄清问题。
1年前关闭。
Improve this question
我用SwiftUI-FirebaseFirerestore制作ChatApp。我同时运行2个模拟器,如果用户A向用户B发送消息,我必须重新加载用户B的界面以显示。我希望它是自动的,并立即显示,那么该怎么做?
已关闭,此问题需要details or clarity。目前不接受答复。
**想改善这个问题吗?**通过editing this post添加详细信息并澄清问题。
1年前关闭。
Improve this question
我用SwiftUI-FirebaseFirerestore制作ChatApp。我同时运行2个模拟器,如果用户A向用户B发送消息,我必须重新加载用户B的界面以显示。我希望它是自动的,并立即显示,那么该怎么做?
1条答案
按热度按时间b4lqfgs41#
您要查找的内容称为快照侦听器。实际上,它的处理方式与任何其他文档相同,但它有一个闭包,允许您响应特定文档上的更新事件。它的一般用法是这样的。
您应该能够查看文档快照以确定数据中的任何更改,然后响应这些更改。在本例中,您将重新加载视图。
https://firebase.google.com/docs/firestore/query-data/listen