nativescript-vue / nativescript-vue.org

NativeScript-Vue website
https://nativescript-vue.org/
MIT License
115 stars 157 forks source link

Why is the Vue Router unsupported? #316

Open Znegl opened 4 years ago

Znegl commented 4 years ago

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 commented 4 years ago

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

rigor789 commented 4 years ago

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)

posva commented 4 years ago

@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 notifications@github.com 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.

Znegl commented 4 years ago

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

rigor789 commented 4 years ago

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!

gregpalaci commented 4 years ago

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