-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Passing an array of promises #4
Comments
I thought about adding events to the single promise as well. Do you have any use case for single promises? |
Hum, you can think about a sync function (update a vuex store or an indexeddb store) on success or when the error is not displayed by the component itself (add a toast to a list managed in a vuex store) |
"the result of a promise can be more than just data display" In this case you probably shouldn't handle the promise logic in the template layer. I gave events a try, sending the promise to be resolved to the template layer only to then send the result back to the script layer felt convoluted (at least the way I implemented it). |
I agree. When you want to display a toast instead of an error, you are probably doing a request in the js (eg: login in the navbar) |
What if it just used/behaved like Promise.all?
If you wanted to wait for the promises individually, you could do:
|
@Herteby In that case you would just pass the promise returned by Promise.all to the usual promise prop 😄 |
@posva True I suppose. Promise.all isn't available in the template scope though, and when you have a lot of |
Oh no, you need to use it in the computed property. I actually think it's a bad idea to have an extra layer of complexity for this because it hides away a very simple call regarding promises that a js developer could benefit when writing other code that deals with promises |
I'm dropping the array of promises as with the new combined slot it's easier to just loop over an array of promises to display multiple Promised components and on top of that the order is preserved |
Currently, it is possible to pass an array of promises as
promises
but I'm not sure the approach is flexible enough. Maybe it should be in another component that is more flexible, eg:slot-scope="{ resolved, pending, all }"
I'm open to suggestions and usecases
The text was updated successfully, but these errors were encountered: