ccstate-vue 4.2.0 → 4.3.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/CHANGELOG.md +7 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/package.json +2 -2
- package/src/useSet.ts +8 -8
package/CHANGELOG.md
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Store, Computed, State,
|
|
1
|
+
import { Store, Computed, State, StateArg, Command } from 'ccstate';
|
|
2
2
|
import { ShallowRef } from 'vue';
|
|
3
3
|
|
|
4
4
|
declare const provideStore: (store: Store) => void;
|
|
@@ -6,7 +6,7 @@ declare const useStore: () => Store;
|
|
|
6
6
|
|
|
7
7
|
declare function useGet<Value>(atom: Computed<Value> | State<Value>): Readonly<ShallowRef<Value>>;
|
|
8
8
|
|
|
9
|
-
declare function useSet<T>(atom: State<T>): (value:
|
|
10
|
-
declare function useSet<T,
|
|
9
|
+
declare function useSet<T>(atom: State<T>): (value: StateArg<T>) => void;
|
|
10
|
+
declare function useSet<T, CommandArgs extends unknown[]>(atom: Command<T, CommandArgs>): (...args: CommandArgs) => T;
|
|
11
11
|
|
|
12
12
|
export { provideStore, useGet, useSet, useStore };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Store, Computed, State,
|
|
1
|
+
import { Store, Computed, State, StateArg, Command } from 'ccstate';
|
|
2
2
|
import { ShallowRef } from 'vue';
|
|
3
3
|
|
|
4
4
|
declare const provideStore: (store: Store) => void;
|
|
@@ -6,7 +6,7 @@ declare const useStore: () => Store;
|
|
|
6
6
|
|
|
7
7
|
declare function useGet<Value>(atom: Computed<Value> | State<Value>): Readonly<ShallowRef<Value>>;
|
|
8
8
|
|
|
9
|
-
declare function useSet<T>(atom: State<T>): (value:
|
|
10
|
-
declare function useSet<T,
|
|
9
|
+
declare function useSet<T>(atom: State<T>): (value: StateArg<T>) => void;
|
|
10
|
+
declare function useSet<T, CommandArgs extends unknown[]>(atom: Command<T, CommandArgs>): (...args: CommandArgs) => T;
|
|
11
11
|
|
|
12
12
|
export { provideStore, useGet, useSet, useStore };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ccstate-vue",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "CCState Vue Hooks",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"vue": ">=3.2.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"ccstate": "^4.
|
|
23
|
+
"ccstate": "^4.3.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@babel/preset-env": "^7.26.0",
|
package/src/useSet.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { useStore } from './provider';
|
|
2
|
-
import { type Command, type State, type
|
|
2
|
+
import { type Command, type State, type StateArg } from 'ccstate';
|
|
3
3
|
|
|
4
|
-
export function useSet<T>(atom: State<T>): (value:
|
|
5
|
-
export function useSet<T,
|
|
6
|
-
export function useSet<T,
|
|
7
|
-
atom: State<T> | Command<T,
|
|
8
|
-
): ((value:
|
|
4
|
+
export function useSet<T>(atom: State<T>): (value: StateArg<T>) => void;
|
|
5
|
+
export function useSet<T, CommandArgs extends unknown[]>(atom: Command<T, CommandArgs>): (...args: CommandArgs) => T;
|
|
6
|
+
export function useSet<T, CommandArgs extends unknown[]>(
|
|
7
|
+
atom: State<T> | Command<T, CommandArgs>,
|
|
8
|
+
): ((value: StateArg<T>) => void) | ((...args: CommandArgs) => T) {
|
|
9
9
|
const store = useStore();
|
|
10
10
|
|
|
11
11
|
if ('write' in atom) {
|
|
12
|
-
return (...args:
|
|
12
|
+
return (...args: CommandArgs): T => {
|
|
13
13
|
const ret = store.set(atom, ...args);
|
|
14
14
|
|
|
15
15
|
return ret;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
return (value:
|
|
19
|
+
return (value: StateArg<T>) => {
|
|
20
20
|
store.set(atom, value);
|
|
21
21
|
};
|
|
22
22
|
}
|