@@ -7,15 +7,15 @@ export const simulateError = ref(false)
7
7
export const useUserData = defineColadaLoader ( '/users/colada-loader.[id]' , {
8
8
async query ( to , { signal } ) {
9
9
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
+ } )
13
13
// we need to read these before the delay
14
14
const id = to . params . id
15
15
// @ts -expect-error: no param "name"!
16
16
const name = to . params . name
17
17
18
- await delay ( 500 )
18
+ await delay ( 2000 )
19
19
if ( simulateError . value ) {
20
20
throw new Error ( 'Simulated Error' )
21
21
}
@@ -33,5 +33,13 @@ export const useUserData = defineColadaLoader('/users/colada-loader.[id]', {
33
33
return [ 'loader-users' , to . params . id ]
34
34
} ,
35
35
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
+ } ,
37
45
} )
0 commit comments