Skip to content
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

v-slot `navigate` function - return optional Promise #3042

Open
aeharding opened this issue Nov 27, 2019 · 1 comment
Open

v-slot `navigate` function - return optional Promise #3042

aeharding opened this issue Nov 27, 2019 · 1 comment

Comments

@aeharding
Copy link

@aeharding aeharding commented Nov 27, 2019

What problem does this feature solve?

I am trying to create a button within a router-link that shows a loading indicator when clicked (but still allows opening in a new tab, which should not show a loading indicator).

It would be nice if navigate($event) in the v-slot API could return a promise when it performs a .push/replace() so that I could stop the loading animation when the route fails to load, or succeeds, just like router.push/replace(to) does.

Right now the only way to do this in my app is to implement a programmatic push or replace call, which does not allow opening in a new tab.

Thank you so much!

What does the proposed API look like?

navigate(e) returns a Promise (the result of .push or .replace) if either of those functions are called within navigate(e). If neither is called, return nothing.

@posva

This comment has been minimized.

Copy link
Member

@posva posva commented Nov 27, 2019

It's a bit more complex than just returning the result of push/replace as we also need to support environments with No Promise. https://github.com/vuejs/vue-router/blob/dev/src/components/link.js#L71-L77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.