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
Labels
feature request fixed on 4.x This issue has been already fixed on the v4 but exists in v3

Comments

@aeharding
Copy link

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
Copy link
Member

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

@posva posva added the fixed on 4.x This issue has been already fixed on the v4 but exists in v3 label Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request fixed on 4.x This issue has been already fixed on the v4 but exists in v3
Projects
None yet
Development

No branches or pull requests

2 participants