]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
feat: wip [skip ci]
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 3 Mar 2021 09:25:48 +0000 (10:25 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 28 Jun 2021 15:10:17 +0000 (17:10 +0200)
e2e/suspended-router-view/index.ts

index d9b52eb86b8b6d45a23b7b42613c72df84301fd2..8a94028f835898fc17f64a4d5c720e793866918a 100644 (file)
@@ -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)
   })
 })