solid-state-tools 1.0.3 → 1.1.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/README.md +4 -4
- package/dist/atom.d.ts +3 -3
- package/dist/atom.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,11 +51,11 @@ const [ double, setDouble ] = createCosignal([
|
|
|
51
51
|
]);
|
|
52
52
|
|
|
53
53
|
// Yet, we can still pass a mapping function here.
|
|
54
|
-
|
|
54
|
+
setDouble(x => x + 2);
|
|
55
55
|
console.log(double(), count()); // 12 6
|
|
56
56
|
|
|
57
57
|
// Or simply use it traditionally.
|
|
58
|
-
|
|
58
|
+
setDouble(10);
|
|
59
59
|
console.log(double(), count()); // 10 5
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -69,10 +69,10 @@ const [ double, setDouble ] = createCosignal([
|
|
|
69
69
|
]);
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
Finally, co-signals can be wrapped with `atom
|
|
72
|
+
Finally, co-signals can be wrapped with `atom` to combine their getter and setter.
|
|
73
73
|
|
|
74
74
|
```ts
|
|
75
75
|
const double = atom(createCosignal(/* ... */));
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
To be clear, `createCosignal` and `createSignal` return the same kind of value and therefore should work in every situation native signals do.
|
|
78
|
+
To be clear, `createCosignal` and `createSignal` return the same kind of value (`Signal`) and therefore should work in every situation native signals do.
|
package/dist/atom.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type Signal, type SignalOptions } from "solid-js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Any tuple of two functions where the first accepts no arguments and the second accepts any amount.
|
|
4
4
|
*/
|
|
5
|
-
export type
|
|
5
|
+
export type SignalLike = readonly [() => any, (...args: any) => any];
|
|
6
6
|
/**
|
|
7
7
|
* An atom is a polymorphic function that calls one of two
|
|
8
8
|
* functions depending on the number of arguments it has.
|
|
@@ -10,7 +10,7 @@ export type Atomical = readonly [() => any, (...args: any) => any];
|
|
|
10
10
|
* If called with zero arguments, the first function is called.
|
|
11
11
|
* Otherwise, the second function is called and all of the arguments are forwarded to it.
|
|
12
12
|
*/
|
|
13
|
-
export type Atom<T extends
|
|
13
|
+
export type Atom<T extends SignalLike = SignalLike> = T[0] & T[1];
|
|
14
14
|
/**
|
|
15
15
|
* Combine a getter and setter function pair into one.
|
|
16
16
|
*
|
|
@@ -32,7 +32,7 @@ export type Atom<T extends Atomical = Atomical> = T[0] & T[1];
|
|
|
32
32
|
* count(count() + 1);
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
|
-
export declare function atom<const T extends
|
|
35
|
+
export declare function atom<const T extends SignalLike>(value: T): Atom<T>;
|
|
36
36
|
/**
|
|
37
37
|
* An atomic signal.
|
|
38
38
|
* A signal where the getter and setter are combined into one function.
|
package/dist/atom.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atom.d.ts","sourceRoot":"","sources":["../src/atom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAGlF;;GAEG;AACH,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"atom.d.ts","sourceRoot":"","sources":["../src/atom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAGlF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,CAAE,MAAM,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,CAAE,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,IAAI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