react-hooks-global-states 15.0.2 → 15.0.3
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/createGlobalState.d.ts +11 -2
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/createGlobalState.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionCollectionConfig, ActionCollectionResult, StateHook, BaseMetadata, GlobalStoreCallbacks } from './types';
|
|
1
|
+
import type { ActionCollectionConfig, ActionCollectionResult, StateHook, BaseMetadata, GlobalStoreCallbacks, StoreTools } from './types';
|
|
2
2
|
interface CreateGlobalState {
|
|
3
3
|
/**
|
|
4
4
|
* Creates a global state hook.
|
|
@@ -159,5 +159,14 @@ export declare const createGlobalState: CreateGlobalState;
|
|
|
159
159
|
* type CounterActions = InferActionsType<typeof useCounter>;
|
|
160
160
|
* ```
|
|
161
161
|
*/
|
|
162
|
-
export type InferActionsType<Hook extends StateHook<any, any, any>> = ReturnType<Hook
|
|
162
|
+
export type InferActionsType<Hook extends StateHook<any, any, any>> = ReturnType<Hook>['1'];
|
|
163
|
+
/**
|
|
164
|
+
* Infers the StoreTools type from a StateHook, useful to split actions code
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* type CounterStoreTools = InferStateApi<typeof useCounter>;
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export type InferStateApi<Hook extends StateHook<any, any, any>> = Hook extends StateHook<infer State, infer PublicStateMutator, infer Metadata> ? StoreTools<State, PublicStateMutator, Metadata> : never;
|
|
163
172
|
export default createGlobalState;
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { StateApi, ObservableFragment, MetadataSetter, StateChanges, StoreTools, ActionCollectionResult, GlobalStoreCallbacks, UseHookOptions, UnsubscribeCallback, SubscribeCallbackConfig, SubscribeCallback, BaseMetadata, MetadataGetter, SelectorCallback, SubscriberParameters, SubscriptionCallback, StateHook, ActionCollectionConfig, } from './types';
|
|
2
2
|
export { GlobalStore } from './GlobalStore';
|
|
3
3
|
export { GlobalStoreAbstract } from './GlobalStoreAbstract';
|
|
4
|
-
export { createGlobalState, type InferActionsType } from './createGlobalState';
|
|
4
|
+
export { createGlobalState, type InferActionsType, type InferStateApi } from './createGlobalState';
|
|
5
5
|
export { shallowCompare } from './shallowCompare';
|
|
6
6
|
export { uniqueId } from './uniqueId';
|
|
7
7
|
export { throwWrongKeyOnActionCollectionConfig } from './throwWrongKeyOnActionCollectionConfig';
|
package/package.json
CHANGED