From: Eduardo San Martin Morote Date: Fri, 18 Feb 2022 23:17:34 +0000 (+0100) Subject: feat: wip X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fdiscussion%2Fsuspense;p=thirdparty%2Fvuejs%2Frouter.git feat: wip --- diff --git a/e2e/suspense-view/index.ts b/e2e/suspense-view/index.ts index 1cbbb407..b52718eb 100644 --- a/e2e/suspense-view/index.ts +++ b/e2e/suspense-view/index.ts @@ -16,6 +16,7 @@ import { h, onErrorCaptured, defineAsyncComponent, + onServerPrefetch, } from 'vue' const Home = defineComponent({ diff --git a/e2e/suspense/notes.md b/e2e/suspense/notes.md index 0f93a547..7bf775fa 100644 --- a/e2e/suspense/notes.md +++ b/e2e/suspense/notes.md @@ -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) }) ``` + + Let's consider these routes: - Home `/`: Not Async