Skip to content

Commit

Permalink
chore: unused stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Mar 6, 2024
1 parent ff8b744 commit c2a0c98
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
44 changes: 22 additions & 22 deletions playground/src/pages/users/query.[id].vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
// FIXME: should be able to import from vue-router or auto import
import { defineQueryLoader } from 'unplugin-vue-router/data-loaders/vue-query'
// import { defineQueryLoader } from 'unplugin-vue-router/data-loaders/vue-query'
import {
type TypesConfig,
Expand Down Expand Up @@ -57,33 +57,33 @@ const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
// FIXME: export once doable
// NOTE: it's a bit different from the one in /[name].vue
const useUserData = defineQueryLoader(
'/users/[id]',
async (route, { signal }) => {
console.log('useUserData', route.fullPath)
await delay(700)
const user = {
id: route.params.id,
// @ts-expect-error: no param "name"!
name: route.params.name || 'Edu',
when: new Date().toUTCString(),
}
return user
},
{
queryKey: ['user-id'],
// queryKey: (route) => ['users', route.params.id],
staleTime: 5000,
lazy: false,
}
)
// const useUserData = defineQueryLoader(
// '/users/[id]',
// async (route, { signal }) => {
// console.log('useUserData', route.fullPath)
// await delay(700)
// const user = {
// id: route.params.id,
// // @ts-expect-error: no param "name"!
// name: route.params.name || 'Edu',
// when: new Date().toUTCString(),
// }
// return user
// },
// {
// queryKey: ['user-id'],
// // queryKey: (route) => ['users', route.params.id],
// staleTime: 5000,
// lazy: false,
// }
// )
</script>

<script lang="ts" setup>
import { useQuery } from '@tanstack/vue-query'
const route = useRoute('/users/[id]')
const { data: user, isLoading, error } = useUserData()
// const { data: user, isLoading, error } = useUserData()
const {
data: tqUser,
error: tqError,
Expand Down
1 change: 1 addition & 0 deletions playground/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default defineConfig({
plugins: [
VueRouter({
extensions: ['.page.vue', '.vue', '.md'],
importMode: 'async',
extendRoute(route) {
// console.log('extending route', route.meta)

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default createUnplugin<Options | undefined>((opt = {}, _meta) => {
return ctx.generateVueRouterProxy()
}

return undefined // ok TS...
return // ok TS...
},

// improves DX
Expand Down

0 comments on commit c2a0c98

Please sign in to comment.