repos / starfx

supercharged async flow control library.
git clone https://github.com/neurosnap/starfx.git

commit
471b64e
parent
680d9ea
author
Eric Bower
date
2024-01-03 18:55:22 +0000 UTC
chore(query): export useCache type
2 files changed,  +4, -6
M query/react.ts
+2, -6
 1@@ -1,5 +1,6 @@
 2 import type { LoaderState, QueryState } from "../types.ts";
 3 import { React, useDispatch, useSelector } from "../deps.ts";
 4+import { ThunkAction } from "./types.ts";
 5 const { useEffect, useRef } = React;
 6 
 7 // TODO: remove store deps
 8@@ -8,11 +9,6 @@ import { selectDataById, selectLoaderById } from "../redux/mod.ts";
 9 type ActionFn<P = any> = (p: P) => { toString: () => string };
10 type ActionFnSimple = () => { toString: () => string };
11 
12-interface ThunkAction<P = any> {
13-  type: string;
14-  payload: { key: string; options: P };
15-}
16-
17 export interface UseApiProps<P = any> extends LoaderState {
18   trigger: (p: P) => void;
19   action: ActionFn<P>;
20@@ -31,7 +27,7 @@ export type UseApiResult<P, A extends ThunkAction = ThunkAction> =
21   | UseApiSimpleProps
22   | UseApiAction<A>;
23 
24-interface UseCacheResult<D = any, A extends ThunkAction = ThunkAction>
25+export interface UseCacheResult<D = any, A extends ThunkAction = ThunkAction>
26   extends UseApiAction<A> {
27   data: D | null;
28 }
M query/types.ts
+2, -0
1@@ -101,6 +101,8 @@ export interface CreateActionPayload<P = any> {
2   options: P;
3 }
4 
5+export type ThunkAction<P = any> = ActionWithPayload<CreateActionPayload<P>>;
6+
7 export type CreateActionFn = () => ActionWithPayload<
8   CreateActionPayload<Record<string | number | symbol, never>>
9 >;