Firebase Angularfire snapshotChanges()与Firestore javscript库onSnapshot()的比较
我发现firestore有两个实时监听器Firebase Angularfire snapshotChanges()与Firestore javscript库onSnapshot()的比较,firebase,google-cloud-firestore,angularfire2,Firebase,Google Cloud Firestore,Angularfire2,我发现firestore有两个实时监听器 Angularfire:snapshotChanges() Firestore脚本库:onSnapshot() 这是我的问题 我可以知道有什么不同吗?我应该如何正确使用它们(我正在使用Ionic+Cordova+Angular框架开发) 如何分离快照更改()?请参阅Firestore文档,我可以按照以下步骤分离onSnapshot() 感谢您的分享。AngularFire库不包含名为onSnapshot()的方法。。该方法在javascript云fi
- Angularfire:snapshotChanges()
- Firestore脚本库:onSnapshot()
感谢您的分享。AngularFire库不包含名为
onSnapshot()的方法。
。该方法在javascript云firestore库中使用,用于侦听实时更新
虽然snapshotChanges()
专门用于angularfire,但它返回一个可观察的,因此它将继续侦听数据库中的任何更改并检索数据
要取消订阅,只需调用以下方法:
AngularFire库不包含名为onSnapshot()
的方法。该方法在javascript云firestore库中使用,用于侦听实时更新
虽然snapshotChanges()
专门用于angularfire,但它返回一个可观察的,因此它将继续侦听数据库中的任何更改并检索数据
要取消订阅,只需调用以下方法:
你在哪里看到安格拉尔火的Onsnaphot?谢谢你的指点。我已经更新了我的帖子,其中onsnapshot()来自JS web库,snapshotChanges()来自angularfirestore。似乎我也能在angularfirestore下使用onsnapshot,两者都工作得很好,所以我想知道它们之间有什么区别,使用它们的最佳情况是什么。listener=this.afs.doc(test/${id}/
).ref.onSnapshot()listener=this.afs.doc(test/${id}/
).snapshotChanges().subscribe()如果使用angularfire,那么只需使用snapshotChanges()
,如果使用js web库,则使用onSnapshot()
,两者都将实时检索数据。但是snapshotChanges()
是angularfire库中的一种方法,当您在angularfire中使用angularfire时,您在angularfire中看到OnSnapshot在哪里?谢谢您指出。我已经更新了我的帖子,其中onsnapshot()来自JS web库,snapshotChanges()来自angularfirestore。似乎我也能在angularfirestore下使用onsnapshot,两者都工作得很好,所以我想知道它们之间有什么区别,使用它们的最佳情况是什么。listener=this.afs.doc(test/${id}/
).ref.onSnapshot()listener=this.afs.doc(test/${id}/
).snapshotChanges().subscribe()如果使用angularfire,那么只需使用snapshotChanges()
,如果使用js web库,则使用onSnapshot()
,两者都将实时检索数据。但是snapshotChanges()
是angularfire库中的一种方法,当您在角度项目中工作时,可以使用该方法。snapshotChanges()返回的可观察对象包含什么?可观察对象将观察来自参考位置的数据流,然后当您收到调用subscribe()
时,您可以访问数据@arcrub snapshotChanges()返回的可观察对象包含哪些内容?可观察对象将观察来自参考位置的数据流,然后当您收到callsubscribe()
时,您可以访问数据@弧光
var unsubscribe = db.collection("cities")
.onSnapshot(function (){
// Respond to data
// ...
});
// Later ...
// Stop listening to changes
unsubscribe();
//Subscribe
subscription = this.itemRef.snapshotChanges().subscribe();
//Unsubscribe
subscription.unsubscribe()