nativescript-vue.org icon indicating copy to clipboard operation
nativescript-vue.org copied to clipboard

Why is the Vue Router unsupported?

Open Znegl opened this issue 5 years ago • 6 comments
trafficstars

According to the docs the Vue Router is unsupported and we have to wait for the team to resolve the issue. Looking at the git history for the page, the Vue Router was first supported, then experimental and then unsupported, without ever explaining what the issue was or is. Furthermore there is no link to the issue anywhere, which makes it a bit hard to keep track of. Could you please elaborate on why it's unsupported? It would make it easier how to handle the limitation. It might also help someone else figuring out a solution to the problem.

We're currently in the process of starting a project requiring code sharing between the web and native apps and we would really really like to use the Vue router and not reinvent routing for our entire app because the NativeScript version of it doesn't support the router.

Znegl avatar Dec 18 '19 13:12 Znegl

https://nativescript-vue.org/en/docs/routing/vue-router/

Znegl avatar Dec 18 '19 13:12 Znegl

I agree the wording is a little misleading - there isn't a specific outstanding issue that we need to resolve.

The progress has been logged here: https://github.com/nativescript-vue/nativescript-vue/issues/214.

Both @bundyo and I have spent a lot of time figuring out how to make it work, but we've always came across cases where things would start acting up (In very common scenarios too).

What it boils down to is that web routing doesn't have the idea of a backstack, where previous pages are kept alive (a good analogy would be like having a separate tab open for every page of the backstack, you can go back to any of them and be right back where you left off) - instead it has a history, that basically just stores the "url"'s to the previous routes.

The way native apps work is that you don't replace the current page whenever navigating, but rather push the new page on top of the current one.

What VueRouter does is keep track of the history, and render the active page inside <router-view> and does not allow customizing when things are rendered, nor how - which makes it difficult to integrate with the NativeScript's navigation system ($navigateTo, $navigateBack in case of NativeScript-Vue).

I'm hopeful that we can figure out a better solution for Vue 3, since as far as I'm aware the VueRouter will get a full rewrite soon. (Maybe @posva could confirm this)

rigor789 avatar Dec 18 '19 16:12 rigor789

@rigor789 in the next version you will be able to override the history implementation by respecting an interface. We can see if that works for you or if there is anything to add to given interface. Combining that with overriding the router view component should give you the flexibility you need.

Eduardo San Martin Morote

On 18 Dec 2019, at 17:28, Igor Randjelovic [email protected] wrote:

 I agree the wording is a little misleading - there isn't a specific outstanding issue that we need to resolve.

The progress has been logged here: nativescript-vue/nativescript-vue#214.

Both @bundyo and I have spent a lot of time figuring out how to make it work, but we've always came across cases where things would start acting up (In very common scenarios too).

What it boils down to is that web routing doesn't have the idea of a backstack, where previous pages are kept alive (a good analogy would be like having a separate tab open for every page of the backstack, you can go back to any of them and be right back where you left off) - instead it has a history, that basically just stores the "url"'s to the previous routes.

The way native apps work is that you don't replace the current page whenever navigating, but rather push the new page on top of the current one.

What VueRouter does is keep track of the history, and render the active page inside and does not allow customizing when things are rendered, nor how - which makes it difficult to integrate with the NativeScript's navigation system ($navigateTo, $navigateBack in case of NativeScript-Vue).

I'm hopeful that we can figure out a better solution for Vue 3, since as far as I'm aware the VueRouter will get a full rewrite soon. (Maybe @posva could confirm this)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

posva avatar Dec 19 '19 11:12 posva

Great! Thanks for the quick and informative answers, both of you!

Znegl avatar Dec 19 '19 12:12 Znegl

That's great @posva, thanks for the feedback! I do think the ability to add a custom history/router-view will eliminate most of the obstacles if not all of them!

rigor789 avatar Dec 22 '19 11:12 rigor789

Glad to hear it's being working on @posva , nativescript seems like the most mature solution for mobile and vue, but it's hard to argure production ready apps without the great vue router support :D

jswhisperer avatar Jan 14 '20 00:01 jswhisperer