Skip to content

Commit 305e7ba

Browse files
committed
chore: tests in playground
1 parent b7af276 commit 305e7ba

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

playground/src/loaders/colada-loaders.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ export const simulateError = ref(false)
77
export const useUserData = defineColadaLoader('/users/colada-loader.[id]', {
88
async query(to, { signal }) {
99
console.log('[🍹] coladaLoader', to.fullPath)
10-
// signal.addEventListener('abort', () => {
11-
// console.log('[🍹❌] aborted', to.fullPath)
12-
// })
10+
signal.addEventListener('abort', () => {
11+
console.log('[🍹❌] aborted', to.fullPath)
12+
})
1313
// we need to read these before the delay
1414
const id = to.params.id
1515
// @ts-expect-error: no param "name"!
1616
const name = to.params.name
1717

18-
await delay(500)
18+
await delay(2000)
1919
if (simulateError.value) {
2020
throw new Error('Simulated Error')
2121
}
@@ -33,5 +33,13 @@ export const useUserData = defineColadaLoader('/users/colada-loader.[id]', {
3333
return ['loader-users', to.params.id]
3434
},
3535
staleTime: 10000,
36-
lazy: (to, from) => to.name && to.name === from?.name,
36+
placeholderData: (previousData) => {
37+
console.log('[🍹] placeholderData', previousData)
38+
return previousData
39+
},
40+
lazy: (to, from) => {
41+
const lazy = to.name && to.name === from?.name
42+
console.log('[🍹] lazy', to.fullPath, lazy)
43+
return lazy
44+
},
3745
})

0 commit comments

Comments
 (0)