【发布时间】:2020-02-22 20:13:11
【问题描述】:
我想在我的集合中添加一个侦听器,以便在将文档添加到集合时触发函数“getNewChats()”。
我的 initState 中有以下监听器:
CollectionReference reference = Firestore.instance.collection('chats');
@override
void initState() {
super.initState();
getChats();
reference.snapshots().listen((querySnapshot) {
querySnapshot.documentChanges.forEach((change) {
getNewChats();
});
});
我的问题是,每次运行 init 状态时,我是否需要为阅读“聊天”集合中的每个文档付费,还是仅在集合发生变化(如添加文档)时才付费?
如果是这样,有没有办法只收听最近添加的文档,所以我没有阅读所有内容?
【问题讨论】:
标签: flutter google-cloud-firestore