-
-
Notifications
You must be signed in to change notification settings - Fork 346
Closed
Description
In my vue component I have this:
{
firebase () {
return {
routes: Firebase.database().ref(`items/${this.$store.state.user.uid}`).orderByChild('when').limitToLast(5),
};
},
}
Now I would like to dynamically update this query to either increase limit or change ordering field.
Here is what I tried:
- Make firebase () func in component to depend on some data param:
{
data: { limit: 5 },
methods: {
loadMore () { this.limit = 10; },
},
firebase () {
return {
items: Firebase.database().ref(`items/${this.$store.state.user.uid}`).orderByChild('when').limitToLast(this.limit),
};
},
}
It does not work, firebase() is no called on data.limit change.
- Update query using $firebaseRefs
{
methods: {
loadMore () { this.$firebaseRefs.items.limitToLast(10); },
},
firebase () {
return {
items: Firebase.database().ref(`items/${this.$store.state.user.uid}`).orderByChild('when').limitToLast(5),
};
},
}
It has no effect...
- Update whole firebase binding dynamically
{
methods: {
loadMore () {
this.$bindAsArray('items', Firebase.database().ref(`items/${this.$store.state.user.uid}`).orderByChild('when').limitToLast(10));
},
},
firebase () {
return {
items: Firebase.database().ref(`items/${this.$store.state.user.uid}`).orderByChild('when').limitToLast(5),
};
},
}
It works, but for a moment "items" is empty array and then loads with updated limit. I would like to avoid such "blink" and just display loader on top of current items (5) and just append new items added by changing limit to (10).
Any idea how I can do this?
hol-42 and PaoloDuzioni
Metadata
Metadata
Assignees
Labels
No labels