@@ -47,6 +47,12 @@ import { toLazyValue } from './createDataLoader'
47
47
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. This returns a
48
48
* composable that can be used in any component.
49
49
*
50
+ * The returned composable exposes a mix of Data Loaders state and Pinia
51
+ * Colada state.
52
+ * - `data`, `isLoading`, `error` are navigation dependent and follow data loaders behavior.
53
+ * - `status`, `asyncStatus`, `state` are Pinia Colada state and will immediately change and reflect the state of the
54
+ * query.
55
+ *
50
56
* @experimental
51
57
* Still under development and subject to change. See https://github.com/vuejs/rfcs/discussions/460
52
58
*
@@ -383,7 +389,7 @@ export function defineColadaLoader<Data, isLazy extends boolean>(
383
389
384
390
const { data, error, isLoading, ext } = entry
385
391
386
- // TODO: add watchers only once
392
+ // TODO: add watchers only once alongside the entry
387
393
// update the data when pinia colada updates it e.g. after visibility change
388
394
watch ( ext ! . data , ( newData ) => {
389
395
// only if we are not in the middle of a navigation
@@ -425,8 +431,10 @@ export function defineColadaLoader<Data, isLazy extends boolean>(
425
431
router [ APP_KEY ] . runWithContext ( ( ) => load ( to , router ) ) . then (
426
432
( ) => ( entry ! . commit ( to ) , entry . ext ! . state . value )
427
433
) ,
428
- isPending : ext ! . isPending ,
429
434
status : ext ! . status ,
435
+ asyncStatus : ext ! . asyncStatus ,
436
+ state : ext ! . state ,
437
+ isPending : ext ! . isPending ,
430
438
} satisfies UseDataLoaderColadaResult < boolean , unknown >
431
439
432
440
// load ensures there is a pending load
@@ -496,7 +504,7 @@ export interface UseDataLoaderColadaResult<isLazy extends boolean, Data>
496
504
extends UseDataLoaderResult < isLazy , Data > ,
497
505
Pick <
498
506
UseQueryReturn < Data , any > ,
499
- 'isPending' | 'refetch' | 'refresh' | 'status'
507
+ 'isPending' | 'refetch' | 'refresh' | 'status' | 'asyncStatus' | 'state'
500
508
> { }
501
509
502
510
/**
0 commit comments