): Promise<any> {
let guards: Lazy<any>[]
+ const [
+ leavingRecords,
+ updatingRecords,
+ enteringRecords,
+ ] = extractChangingRecords(to, from)
+
// all components here have been resolved once because we are leaving
guards = extractComponentsGuards(
- from.matched.filter(record => to.matched.indexOf(record) < 0).reverse(),
+ leavingRecords.reverse(),
'beforeRouteLeave',
to,
from
)
- const [
- leavingRecords,
- updatingRecords,
- // enteringRecords,
- ] = extractChangingRecords(to, from)
-
for (const record of leavingRecords) {
for (const guard of record.leaveGuards) {
guards.push(guardToPromiseFn(guard, to, from))
.then(() => {
// check in components beforeRouteUpdate
guards = extractComponentsGuards(
- to.matched.filter(
- record => from.matched.indexOf(record as any) > -1
- ),
+ updatingRecords,
'beforeRouteUpdate',
to,
from
// check in-component beforeRouteEnter
guards = extractComponentsGuards(
- // the type doesn't matter as we are comparing an object per reference
- to.matched.filter(
- record => from.matched.indexOf(record as any) < 0
- ),
+ enteringRecords,
'beforeRouteEnter',
to,
from