-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
feat: allow Vue component to receive a VueRouter factory #2791
Conversation
Hi, I don't get why you can't reuse the same router instance |
hi posva, in micro-frontend architecture we usually wrap vue apps in web-component to reuse as independent widget in another SPA. As for vue component option design if you happen to destroy and recreate one of these widget (for ex routing from a page to another and back) you find the widget to be in the last route since even if the vue app is destroyed, the reference of the router that will be taken by the new vue app is the same. |
Forgot to mention that Vuex, for example, has taken the same approach in its mixin beforeCreate hook. |
I need this on my project too, hope it will merged. |
Hi there, Could be useful for me too. |
@posva @Silentscripter |
@Silentscripter |
Sorry for the delay, I've been busy these days. Will fix in this week for sure! |
conflict resolved |
The problem with this is that this should not be enough as router instances do not have a way to be destroyed yet (releasing listeners and others). So there is a few more things to check first |
I will try to have a look for a solution, thanks for your comment |
Hello I'm coming back to this since a different PR that should help micro frontends was merged and released recently #3172 The corresponding API added to Vuex was to delay the store instantiation (vuejs/vuex#798) I'm still confused by why you need a function here. Don't you instantiate the root component again? function createVueApp() {
// cleanup existing #app element
const router = new Router()
new Vue({ router, el: '#app' })
} |
Closing due to inactivity. Please open a new issue with a reference to this one if you can follow up with more information. |
In some situations (for ex. micro-frontend architectures where vue apps are wrapped in web-components) it would be good to have different VueRouter instances when a wrapped vue app is destroyed and recreated (since normally the VueRouter is created before and referenced in Vue component options).