From 7c77de416678f3341fc07e0e3fac2570e7e9e05b Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 3 Mar 2021 10:25:48 +0100 Subject: [PATCH] feat: wip [skip ci] --- e2e/suspended-router-view/index.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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) }) }) -- 2.47.2