-
-
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
Component Events #311
Comments
I think this could be very useful for observability and better error handling (such as tentatively recovering from errors) |
Your solution looks good, and I believe it would be the best solution in most cases. As a workaround, would getting the Promise in the script and using it directly work? This doesn't require watchers. E.g. for the case you outlined above: const apiCallPromise = ref(makeApiCall())
apiCallPromise.value.catch(
(reason) => hdlRejected(reason)
) <promised :promise="apiCallPromise">
<!-- Some UI Code here -->
</promised |
Promised fires 'resolved' event when the promise is resolved, fires 'rejected' event when the promise is rejected and fires 'pending' event when pending delay time is elapsed. close posva#311
This is exactly my use-case. The workaround proposed by @darrylnoakes is on point (thanks), but the proposed API is obviously more elegant and clean. |
What problem is this solving
Currently there is no way without using a watcher to invoke a function upon promise resolution or rejection. In the app I'm working on we use notifications when something goes wrong. I can't invoke the notification service from the template.
Proposed solution
Emit
@resolved
and@rejected
events from the promised component when the promise is resolved or rejected.Example Usage
The text was updated successfully, but these errors were encountered: