]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
feat: wip discussion/suspense
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 18 Feb 2022 23:17:34 +0000 (00:17 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 18 Feb 2022 23:17:34 +0000 (00:17 +0100)
e2e/suspense-view/index.ts
e2e/suspense/notes.md

index 1cbbb4074b81b90b9ccb77b8ffaed535b50eeca4..b52718ebbd623719fdb0f987586d746af7ee535a 100644 (file)
@@ -16,6 +16,7 @@ import {
   h,
   onErrorCaptured,
   defineAsyncComponent,
+  onServerPrefetch,
 } from 'vue'
 
 const Home = defineComponent({
index 0f93a547ef0176e2d5f9abdc60a64b08708ae27e..7bf775fa071d5b0094ef520ef3fb4f9719ef4856 100644 (file)
@@ -136,18 +136,21 @@ import { getUser } from './api'
 /**
  * This is the component for /users/:id, it fetches the user information and display it.
  */
-const user = ref()
+const user = useDataFetching()
 
-// +--- Allows blocking the initial navigation
+// +--- Allows blocking the entering navigation
 // |
 // v
-await onBeforeNavigation(async (to, from) => {
+onBeforeNavigation(async (to, from) => {
   // this will be executed on any navigation except when leaving (we can have a different hook like `onBeforeEach()`)
-  user.value = await getUser(to.params.id)
+  await user.fetch(to.params.id)
+  // user.value = await getUser(to.params.id)
 })
 </script>
 ```
 
+
+
 Let's consider these routes:
 
 - Home `/`: Not Async