Open msaelices opened 5 years ago
I was able to lean on the existing $router variable by doing these hackish changes on startup as a temporary workaround. It's still better than having conditional code for web and native everywhere that needs to route somewhere... I'm sure there will be more things to add and address, but simplifies downstream code quite a bit from what I can tell.
Navigator.push = route => {
Vue.prototype.$navigator.navigate(route);
};
Navigator.init = () => {};
Navigator.history = {
current: "/"
};
Then when creating the Vue instance you can change to...
new Vue({
router: Navigator,
store,
render: h => h("frame", [h(App)])
}).$start();
For the sake of the code sharing experience, it would be great that:
$router
$navigator.navigate(to, options)
method would be$router.push(to, options)
$router.replace(to)
would be implemented as the current$navigator.navigate(to, {clearhistory: true})
$router.go(-1)
would be implemented as the current$navigator.back()
If this was refactored, the basic navigation could be shared for mobile and web. And this would be an excellent starting point for a better
vue-router
integration with other non-web implementations.