react-shared-states 1.0.0
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/.editorconfig +9 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +112 -0
- package/LICENSE +21 -0
- package/README.md +359 -0
- package/assets/banner.png +0 -0
- package/dist/SharedData.d.ts +25 -0
- package/dist/context/SharedStatesContext.d.ts +11 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/use-shared-function.d.ts +29 -0
- package/dist/hooks/use-shared-state.d.ts +17 -0
- package/dist/hooks/use-shared.d.ts +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/main.js +820 -0
- package/dist/main.min.js +37 -0
- package/dist/types.d.ts +6 -0
- package/package.json +50 -0
- package/pnpm-workspace.yaml +2 -0
- package/vite.config.ts +45 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AFunction, NonEmptyString, Prefix } from '../types';
|
|
2
|
+
import { SharedApi } from '../SharedData';
|
|
3
|
+
type SharedFunctionsState<T> = {
|
|
4
|
+
fnState: {
|
|
5
|
+
results?: T;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
error?: unknown;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare class SharedFunctionsApi implements SharedApi<SharedFunctionsState<unknown>> {
|
|
11
|
+
get<T, S extends string = string>(key: NonEmptyString<S>, scopeName?: Prefix): T;
|
|
12
|
+
set<T, S extends string = string>(key: NonEmptyString<S>, fnState: SharedFunctionsState<T>, scopeName?: Prefix): void;
|
|
13
|
+
clearAll(): void;
|
|
14
|
+
clear(key: string, scopeName?: Prefix): void;
|
|
15
|
+
has(key: string, scopeName?: Prefix): boolean;
|
|
16
|
+
getAll(): Map<string, import('..').DataMapValue & SharedFunctionsState<unknown>>;
|
|
17
|
+
}
|
|
18
|
+
export declare const sharedFunctionsApi: SharedFunctionsApi;
|
|
19
|
+
export declare const useSharedFunction: <T, Args extends unknown[], S extends string = string>(key: NonEmptyString<S>, fn: AFunction<T, Args>, scopeName?: Prefix) => {
|
|
20
|
+
readonly state: {
|
|
21
|
+
results?: unknown;
|
|
22
|
+
isLoading: boolean;
|
|
23
|
+
error?: unknown;
|
|
24
|
+
};
|
|
25
|
+
readonly trigger: (...args: Args) => void;
|
|
26
|
+
readonly forceTrigger: (...args: Args) => void;
|
|
27
|
+
readonly clear: () => void;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NonEmptyString, Prefix } from '../types';
|
|
2
|
+
import { SharedApi } from '../SharedData';
|
|
3
|
+
declare class SharedStatesApi implements SharedApi<{
|
|
4
|
+
value: unknown;
|
|
5
|
+
}> {
|
|
6
|
+
get<T, S extends string = string>(key: NonEmptyString<S>, scopeName?: Prefix): T;
|
|
7
|
+
set<T, S extends string = string>(key: NonEmptyString<S>, value: T, scopeName?: Prefix): void;
|
|
8
|
+
clearAll(): void;
|
|
9
|
+
clear(key: string, scopeName?: Prefix): void;
|
|
10
|
+
has(key: string, scopeName?: Prefix): boolean;
|
|
11
|
+
getAll(): Map<string, import('..').DataMapValue & {
|
|
12
|
+
value: unknown;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
export declare const sharedStatesApi: SharedStatesApi;
|
|
16
|
+
export declare const useSharedState: <T, S extends string = string>(key: NonEmptyString<S>, value: T, scopeName?: Prefix) => readonly [T, (newValueOrCallbackToNewValue: T | ((prev: T) => T)) => void];
|
|
17
|
+
export {};
|
package/dist/index.d.ts
ADDED