Firestore SDK for NodeJS CollectionReference.onSnapshot(querySnapshotCallback ... ) 它是否像在客户端上那样带来实时更新?
Firestore SDK for NodeJS CollectionReference.onSnapshot(querySnapshotCallback ... ) does it brings RT updates as it does on clients?
这是否意味着只要 sdk firestore 客户端处于活动状态,即使在服务器端,每当数据库中的数据发生变化时,我的回调也会得到更新?
更具体地说,只要添加了侦听器,您的回调就会被调用,并且进程保持活动状态。您可以期望调用回调 when the results of the query change over time。来自文档:
You can listen to a document with the onSnapshot() method. An initial call using the callback you provide creates a document snapshot immediately with the current contents of the single document. Then, each time the contents change, another call updates the document snapshot.
您应该detach the listener根据需要停止此效果。
如果实时结果不是您想要的,请使用 get()
代替 fetch documents a single time。
这是否意味着只要 sdk firestore 客户端处于活动状态,即使在服务器端,每当数据库中的数据发生变化时,我的回调也会得到更新?
更具体地说,只要添加了侦听器,您的回调就会被调用,并且进程保持活动状态。您可以期望调用回调 when the results of the query change over time。来自文档:
You can listen to a document with the onSnapshot() method. An initial call using the callback you provide creates a document snapshot immediately with the current contents of the single document. Then, each time the contents change, another call updates the document snapshot.
您应该detach the listener根据需要停止此效果。
如果实时结果不是您想要的,请使用 get()
代替 fetch documents a single time。