@chhsiao1981/use-thunk 9.0.0 → 9.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/useThunk.ts +3 -1
- package/types/index.d.ts +2 -2
- package/types/useThunk.d.ts +2 -1
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -15,10 +15,11 @@ import { setData } from './setData'
|
|
|
15
15
|
import { getNode, getRootID, getState } from './states'
|
|
16
16
|
import type { ClassState, NodeMeta, NodeState, NodeStateMap, State } from './stateTypes'
|
|
17
17
|
import type { ThunkModule, ThunkModuleToFunc } from './thunk'
|
|
18
|
-
import useThunk from './useThunk'
|
|
18
|
+
import useThunk, { type UseThunk } from './useThunk'
|
|
19
19
|
|
|
20
20
|
export {
|
|
21
21
|
useThunk,
|
|
22
|
+
type UseThunk,
|
|
22
23
|
// StateType, // XXX for global state
|
|
23
24
|
type State,
|
|
24
25
|
type NodeState,
|
package/src/useThunk.ts
CHANGED
|
@@ -7,6 +7,8 @@ import type { ThunkModule, ThunkModuleFunc } from './thunk'
|
|
|
7
7
|
import { DEFAULT_THUNK_MODULE_FUNC_MAP } from './thunkModuleFuncMap'
|
|
8
8
|
import useThunkReducer from './thunkReducer'
|
|
9
9
|
|
|
10
|
+
export type UseThunk<S extends State, R extends ThunkModuleFunc<S>> = [ClassState<S>, DispatchFuncMap<S, R>]
|
|
11
|
+
|
|
10
12
|
/**********
|
|
11
13
|
* useThunk
|
|
12
14
|
**********/
|
|
@@ -14,7 +16,7 @@ export default <S extends State, R extends ThunkModuleFunc<S>>(
|
|
|
14
16
|
theDo: ThunkModule<S, R>,
|
|
15
17
|
// biome-ignore lint/suspicious/noExplicitAny: params can by any types.
|
|
16
18
|
init?: (...params: any[]) => S,
|
|
17
|
-
):
|
|
19
|
+
): UseThunk<S, R> => {
|
|
18
20
|
const { myClass } = theDo
|
|
19
21
|
|
|
20
22
|
// 1. dispatchMapByClass
|
package/types/index.d.ts
CHANGED
|
@@ -15,5 +15,5 @@ import { setData } from './setData';
|
|
|
15
15
|
import { getNode, getRootID, getState } from './states';
|
|
16
16
|
import type { ClassState, NodeMeta, NodeState, NodeStateMap, State } from './stateTypes';
|
|
17
17
|
import type { ThunkModule, ThunkModuleToFunc } from './thunk';
|
|
18
|
-
import useThunk from './useThunk';
|
|
19
|
-
export { useThunk, type State, type NodeState, type NodeMeta, type NodeStateMap, type ClassState, type GetClassState, type Thunk, type ThunkModule, type ThunkModuleToFunc, type Dispatch, type DispatchFuncMap, getRootID, getNode, getState, getChildIDs, getChildID, getLinkIDs, getLinkID, init, type InitParams, setData, remove, addChild, removeChild, addLink, removeLink, type AddRelationAction, type RemoveRelationAction, genUUID, };
|
|
18
|
+
import useThunk, { type UseThunk } from './useThunk';
|
|
19
|
+
export { useThunk, type UseThunk, type State, type NodeState, type NodeMeta, type NodeStateMap, type ClassState, type GetClassState, type Thunk, type ThunkModule, type ThunkModuleToFunc, type Dispatch, type DispatchFuncMap, getRootID, getNode, getState, getChildIDs, getChildID, getLinkIDs, getLinkID, init, type InitParams, setData, remove, addChild, removeChild, addLink, removeLink, type AddRelationAction, type RemoveRelationAction, genUUID, };
|
package/types/useThunk.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { DispatchFuncMap } from './dispatchFuncMap';
|
|
2
2
|
import type { ClassState, State } from './stateTypes';
|
|
3
3
|
import type { ThunkModule, ThunkModuleFunc } from './thunk';
|
|
4
|
+
export type UseThunk<S extends State, R extends ThunkModuleFunc<S>> = [ClassState<S>, DispatchFuncMap<S, R>];
|
|
4
5
|
/**********
|
|
5
6
|
* useThunk
|
|
6
7
|
**********/
|
|
7
|
-
declare const _default: <S extends State, R extends ThunkModuleFunc<S>>(theDo: ThunkModule<S, R>, init?: (...params: any[]) => S) =>
|
|
8
|
+
declare const _default: <S extends State, R extends ThunkModuleFunc<S>>(theDo: ThunkModule<S, R>, init?: (...params: any[]) => S) => UseThunk<S, R>;
|
|
8
9
|
export default _default;
|