https://firebase.google.com/docs/database/web/retrieve-data#read_data_once
Is there such a once() function/parameter?
I'm not sure if this something AngularFire should do, Angular, RSJX, similar. Or there is a way to unsubscribe from the observable.
To give an example why I'm looking for this. I have the main page of the app that lists the last 10 items (newest first) that are for sale (books, chairs, etc.). I don't want this list to be updated as soon as another user creates a new item.
Am I worrying about something that shouldn't happen once I query by limitToLast: 10 for example?
You'll find everything you need to know here #380
thanks @danielordonez !
this works for me
constructor(public db: AngularFireDatabase
)
...
...
function someThing(){
return this.db.list("/dataBase").query.once("value")
}
regards
@hcallejas Thank you! That worked like a charm.
I thought I would share a more elaborate example for those that would like to see this in action.
backup() {
this.afdb.object('/articles').query.once("value").then(data => {
let timestamp = Math.ceil(new Date().getTime() / 1000);
this.afdb.object(`/article_backups/${timestamp}`).set(data.val())
alert(`Article backup created: ${timestamp}`)
})
}
Most helpful comment
this works for me
constructor(public db: AngularFireDatabase
)
...
...
function someThing(){
return this.db.list("/dataBase").query.once("value")
}
regards