-
-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically expose promises when using firestore option #245
Comments
I have thought about this before but I'm not convinced at all because it can already be achieved: new Vue({
data: {
// Usually an array for collection
todos: [],
// and null for documents
currentTodo: null,
todosPromise: null,
currentTodoPromise: null,
},
created () {
this.todosPromise = this.$bind('todos', db.collection('todos'))
this.currentTodoPromise = this.$bind('currentTodo', db.collection('todos').doc('1'))
},
}) It also works pretty well with a computed property which also works for automatic rebinding computed: {
currentTodo: vm => vm.$bind('currentTodo', db.collection('todos').doc(vm.currentTodoId))
} Also, in SSR one would wait for the promise directly. |
2 thoughs:
PS: Excuse my ignorance but in which situations is the automatic rebinding useful? Thanks! |
Why would we want to use promises instead of async/await? |
It's the same thing |
I apologize, my last question was rhetorical. It would seem like a step backwards (sideways at best) to put effort into supporting promises in the exposed API when the JavaScript world is moving from callbacks to async/await. This is the context that statement was meant to be taken in: https://getstream.io/blog/javascript-promises-and-why-async-await-wins-the-battle/ |
I believe that what we're looking for is something parallel to the AngularFire $loaded event. The computed method above works for me for now, but in future I'd like a single event to be fired when all vuefire promises have been resolved without the developer having to replicate all of the individual data variable names in a computed or created and maintain that list in two sections of the component. I'd like to see this implemented as a vue lifecycle function that would get called when all vuefire calls have returned:
|
😄 |
FYI this is now possible with the composables |
It would be useful to be able to use the short firestore notation and still be able to access the promises, for usage with vue-promised for instance.
There are not a lot of situation where data is loaded asynchronously, and a loader indicator is not necessary.
i.e.
The text was updated successfully, but these errors were encountered: