1- import { useAsyncKey } from "../use-utils " ;
1+ import type { AsyncData , NuxtError } from "#app " ;
22import type { BoundT } from "./types" ;
33import type { BaseCRUDAPI , BaseCRUDAPIReadOnly } from "~/lib/api/base/base-clients" ;
44import type { QueryValue } from "~/lib/api/base/route" ;
55
66interface ReadOnlyStoreActions < T extends BoundT > {
7- getAll ( page ?: number , perPage ?: number , params ?: any ) : Ref < T [ ] | null > ;
7+ getAll ( page ?: number , perPage ?: number , params ?: any ) : AsyncData < T [ ] | null , NuxtError < unknown > | null > ;
88 refresh ( page ?: number , perPage ?: number , params ?: any ) : Promise < void > ;
99}
1010
@@ -21,6 +21,7 @@ interface StoreActions<T extends BoundT> extends ReadOnlyStoreActions<T> {
2121 * a lot of refreshing hooks to be called on operations
2222 */
2323export function useReadOnlyActions < T extends BoundT > (
24+ storeKey : string ,
2425 api : BaseCRUDAPIReadOnly < T > ,
2526 allRef : Ref < T [ ] | null > | null ,
2627 loading : Ref < boolean > ,
@@ -29,7 +30,7 @@ export function useReadOnlyActions<T extends BoundT>(
2930 params . orderBy ??= "name" ;
3031 params . orderDirection ??= "asc" ;
3132
32- const allItems = useAsyncData ( useAsyncKey ( ) , async ( ) => {
33+ const allItems = useAsyncData ( storeKey , async ( ) => {
3334 loading . value = true ;
3435 try {
3536 const { data } = await api . getAll ( page , perPage , params ) ;
@@ -80,6 +81,7 @@ export function useReadOnlyActions<T extends BoundT>(
8081 * a lot of refreshing hooks to be called on operations
8182 */
8283export function useStoreActions < T extends BoundT > (
84+ storeKey : string ,
8385 api : BaseCRUDAPI < unknown , T , unknown > ,
8486 allRef : Ref < T [ ] | null > | null ,
8587 loading : Ref < boolean > ,
@@ -88,7 +90,7 @@ export function useStoreActions<T extends BoundT>(
8890 params . orderBy ??= "name" ;
8991 params . orderDirection ??= "asc" ;
9092
91- const allItems = useAsyncData ( useAsyncKey ( ) , async ( ) => {
93+ const allItems = useAsyncData ( storeKey , async ( ) => {
9294 loading . value = true ;
9395 try {
9496 const { data } = await api . getAll ( page , perPage , params ) ;
0 commit comments