2021年5月6日星期四

How to use valueChanges to only read data once in firebase database?

My ionic 5 (Angular) project uses Google firebase database.

This is an example code I used to read data from firebase database. I just want to read the data only once. As valueChanges() is a observable, I guess I have to unsubscribe the subscription every time when use it.

constructor(db: AngularFireDatabase) {      this.tempsub = db.list('items').valueChanges().subscribe(data=>{...});      this.tempsub.unsubscribe()    }  

Do I have to unsubscribe it in my use case? Is there a better solution to read the data from firebase database only once?

https://stackoverflow.com/questions/67428536/how-to-use-valuechanges-to-only-read-data-once-in-firebase-database May 07, 2021 at 11:10AM

没有评论:

发表评论