This is basically a shot at #204 , which is to add a function beforeRouteChange that may return true/false, if return false, prevent the history from being changed at all.
However I'm encountering a few problems, which is why it's still WIP. The biggest one:
Currently, in my implementation, beforeRouteChange is given to the Router component like so <Router {routes} {beforeRouteChange} />
But in the current codebase, pushlinkpop are not in the component itself <script> but in the module part <script context="module".
The problem is that in theory, I need to access beforeRouteChange in push to actually confirm we want to change the route
But it is not possible to call something from "module" to the component itself, because there might be multiple components of the same kind. However, in the case of router, it does not make much sense to have multiple Router instantiated at the same time (or does it? does anyone use 2 routers?).
The question is simple: what can I do to fix this?
For now, this doesn't compile, but you may have a look at the code to see how it looks and if there are improvements. I'm posting this here a bit early to try to solve how to fix this issue.
This is basically a shot at #204 , which is to add a function
beforeRouteChange
that may return true/false, if return false, prevent the history from being changed at all.However I'm encountering a few problems, which is why it's still WIP. The biggest one:
Currently, in my implementation,
beforeRouteChange
is given to theRouter
component like so<Router {routes} {beforeRouteChange} />
But in the current codebase,push
link
pop
are not in the component itself<script>
but in the module part<script context="module"
. The problem is that in theory, I need to accessbeforeRouteChange
in push to actually confirm we want to change the route But it is not possible to call something from "module" to the component itself, because there might be multiple components of the same kind. However, in the case of router, it does not make much sense to have multipleRouter
instantiated at the same time (or does it? does anyone use 2 routers?).The question is simple: what can I do to fix this?
For now, this doesn't compile, but you may have a look at the code to see how it looks and if there are improvements. I'm posting this here a bit early to try to solve how to fix this issue.