From: Eduardo San Martin Morote Date: Wed, 3 Mar 2021 09:25:48 +0000 (+0100) Subject: feat: wip [skip ci] X-Git-Tag: v4.0.11~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c77de416678f3341fc07e0e3fac2570e7e9e05b;p=thirdparty%2Fvuejs%2Frouter.git feat: wip [skip ci] --- diff --git a/e2e/suspended-router-view/index.ts b/e2e/suspended-router-view/index.ts index d9b52eb8..8a94028f 100644 --- a/e2e/suspended-router-view/index.ts +++ b/e2e/suspended-router-view/index.ts @@ -78,12 +78,14 @@ const ViewData = defineComponent({ // return false }) - console.log(`wating at ${depth}...`) + console.log(`waiting at ${depth}...`) await delay(1000) console.log(`done at ${depth}!`) - if (depth > 1) { - // throw new Error('oops') + if (depth > 0) { + // NOTE: artificial increment because suspense is not emitting + suspenseProps.onPending() + throw new Error('oops') } return { suspenseProps } @@ -148,25 +150,30 @@ router.beforeResolve((to, from) => { // we need at least one, we increment the rest with onPending // should probably be provided and then injected in each routerview to increment the counter // then the resolve could decrement and check if it's under 0 - remainingValidations = 1 + remainingValidations = 0 if (resolveSuspense) { resolveSuspense(false) } pendingRoute.value = to resolveSuspense = () => { + console.log('resolving suspense', remainingValidations - 1) if (--remainingValidations < 1) { - pendingRoute.value = null resolveSuspense = null + rejectSuspense = null resolve() + // pendingRoute.value = null + console.log('✅ Resolved') } } rejectSuspense = reason => { - pendingRoute.value = null + console.log('rejecting suspense') rejectSuspense = null + resolveSuspense = null reject(reason) + // pendingRoute.value = null } - console.log('pendingRoute set') + console.log('pendingRoute set', remainingValidations) }) })