ccstate-svelte 4.2.0 → 4.4.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 +13 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/package.json +3 -3
- package/src/useSet.ts +8 -8
package/CHANGELOG.md
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { State, Computed,
|
|
1
|
+
import { State, Computed, StateArg, Command, Store } from 'ccstate';
|
|
2
2
|
|
|
3
3
|
declare function useGet<T>(atom: State<T> | Computed<T>): {
|
|
4
4
|
subscribe(fn: (payload: T) => void): () => void;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
declare function useSet<T>(atom: State<T>): (value:
|
|
8
|
-
declare function useSet<T,
|
|
7
|
+
declare function useSet<T>(atom: State<T>): (value: StateArg<T>) => void;
|
|
8
|
+
declare function useSet<T, CommandArgs extends unknown[]>(atom: Command<T, CommandArgs>): (...args: CommandArgs) => T;
|
|
9
9
|
|
|
10
10
|
declare const provideStore: (store: Store) => void;
|
|
11
11
|
declare const useStore: () => Store;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { State, Computed,
|
|
1
|
+
import { State, Computed, StateArg, Command, Store } from 'ccstate';
|
|
2
2
|
|
|
3
3
|
declare function useGet<T>(atom: State<T> | Computed<T>): {
|
|
4
4
|
subscribe(fn: (payload: T) => void): () => void;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
declare function useSet<T>(atom: State<T>): (value:
|
|
8
|
-
declare function useSet<T,
|
|
7
|
+
declare function useSet<T>(atom: State<T>): (value: StateArg<T>) => void;
|
|
8
|
+
declare function useSet<T, CommandArgs extends unknown[]>(atom: Command<T, CommandArgs>): (...args: CommandArgs) => T;
|
|
9
9
|
|
|
10
10
|
declare const provideStore: (store: Store) => void;
|
|
11
11
|
declare const useStore: () => Store;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ccstate-svelte",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "CCState Svelte Hooks",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"ccstate": "^4.
|
|
20
|
+
"ccstate": "^4.4.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@babel/preset-env": "^7.26.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"svelte": "^5.15.0",
|
|
39
39
|
"vite": "^6.0.5",
|
|
40
40
|
"vitest": "^2.1.8",
|
|
41
|
-
"ccstate": "^4.
|
|
41
|
+
"ccstate": "^4.4.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "rollup -c",
|
package/src/useSet.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { useStore } from './provider';
|
|
2
|
-
import type { Command,
|
|
2
|
+
import type { Command, State, 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
|
}
|