beforeRouteEnter + beforeRouteUpdate | vue router enter
IbelievethereshouldbearoutehookthatcombinesthefunctionalityofthebeforeRouteEnterandbeforeRouteUpdatehooks.Thishookwouldexecuteafterthecurrentrouteleaves,butbeforethenewrouteisentered.CurrentlybeforeRouteEnteronlyrunsthefirsttimearouteisentered,andbeforeRouteUpdatemustberesolvedbeforetheroutewillleave.ConsiderascenarioinwhichIhavearoutecomponentthatreliesonsomeexternaldatatobeavailablebeforerendering:
I believe there should be a route hook that combines the functionality of the beforeRouteEnter and beforeRouteUpdate hooks. This hook would execute after the current route leaves, but before the new route is entered. Currently beforeRouteEnter only runs the first time a route is entered, and beforeRouteUpdate must be resolved before the route will leave.
Consider a scenario in which I have a route component that relies on some external data to be available before rendering:
<template> <div> {{ special }} </div> </template> <script> import store from @/store export default { computed: { special () { return this.$store.getters[special] } }, beforeRouteEnter (to, from, next) { return store.fetchSpecial(to.params.slug).then(next) } } </script>This will work the first time when navigating to the route, but when refreshing the route with a new slug param, we won’t re-fe...