Use Promise for router onBefore #2260
blank-software
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, the official documentation here states:
And it provides an example using the built-in
confirm()
function. That sounds all good, but does anyone actually use the built-inconfirm()
function? I think the more common use case would be to show a confirmation message with something like SweetAlert, which currently is not possible because onBefore() does not support async callbacks. The built-in confirm() is a rudimentary function that blocks the thread, but if you want to implement a proper confirmation dialog, onBefore() is actually useless for that.I would suggest that the router should accept a promise for
onBefore
, and it should perform the visit only when the promise is fulfilled successfully.Beta Was this translation helpful? Give feedback.
All reactions