简体   繁体   English

Swift 用户界面 Firebase AddSnapShotListeners

[英]Swift UI Firebase AddSnapShotListeners

I am seeing the Firebase call for addSnapshotListener a lot ever since I started learning Swift UI and I don't understand the purpose of using it.自从我开始学习 Swift UI 以来,我经常看到 Firebase 对 addSnapshotListener 的调用,但我不明白使用它的目的。 I know it is used for observing changes or something along those lines but I don't know exactly what it is or when to use it in Swift UI.我知道它用于观察变化或类似的东西,但我不确切知道它是什么或何时在 Swift UI 中使用它。 Any help, or helpful definitions or examples of when it would be a proper time to use it?关于何时适合使用它的任何帮助、有用的定义或示例? Thanks.谢谢。

Let's say you have a travel list app.假设您有一个旅行清单应用程序。 Say all your data save in Firestore.假设您所有的数据都保存在 Firestore 中。 When you add new trip you can send to Firestore and Firestore will save and push to you by addSnapshotListener that new added trip then you can insert that trip in your client travel list.当您添加新行程时,您可以发送到 Firestore,Firestore 将保存并通过 addSnapshotListener 将新添加的行程推送给您,然后您可以将该行程插入您的客户行程列表中。 Or Chat app.或聊天应用程序。 Two client can communicate with addSnapshotListener.两个客户端可以通过addSnapshotListener 进行通信。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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