Firestore中与FLUTTER应用程序等效的ValueEventListener是什么

问题描述 投票:0回答:1

假设我有名称为collection_name的集合,其文档ID为[[signed_user_id,而文档json_content的子级为String,并且为文档中的其他字段。我试图监听子节点(json_content)并仅在该子节点json_content更改时执行一项任务。使用RealTimeDatabase,我可以使用ValueEventListener,但是当我转移到Firestore时,如何收听此子json_content值的更改?]]_listenForValueUpdate() { widget.firestore .collection('collection_name') .document('signed_user_id') .snapshots() .listen((event) { print(event.data); });

}

[假设我有名称为collection_name的集合,其文档ID为sign_user_id,文档json_content的子级为String,并且文档中的其他字段。我正在尝试听...

firebase flutter firebase-realtime-database google-cloud-firestore event-listener
1个回答
0
投票
snapshots()方法等效于ValueEventListener,两者都将实时监听任何更改。但是在Firestore中,您无法侦听文档中的单个字段。如果文档中发生任何更改,snapshot()将提供实时更新。
© www.soinside.com 2019 - 2024. All rights reserved.