@ereo/state 0.1.22 → 0.1.24
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/dist/index.js +9 -3
- package/dist/signals.d.ts +2 -1
- package/dist/signals.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
class Signal {
|
|
4
4
|
_value;
|
|
5
5
|
_subscribers = new Set;
|
|
6
|
-
_derivedFrom = [];
|
|
7
6
|
constructor(initialValue) {
|
|
8
7
|
this._value = initialValue;
|
|
9
8
|
}
|
|
@@ -30,7 +29,11 @@ class Signal {
|
|
|
30
29
|
}
|
|
31
30
|
_notify() {
|
|
32
31
|
for (const subscriber of this._subscribers) {
|
|
33
|
-
|
|
32
|
+
try {
|
|
33
|
+
subscriber(this._value);
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.error("Signal subscriber error:", e);
|
|
36
|
+
}
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
}
|
|
@@ -72,6 +75,9 @@ class Store {
|
|
|
72
75
|
this._state.set(key, signal(value));
|
|
73
76
|
}
|
|
74
77
|
}
|
|
78
|
+
entries() {
|
|
79
|
+
return this._state.entries();
|
|
80
|
+
}
|
|
75
81
|
getSnapshot() {
|
|
76
82
|
const snapshot = {};
|
|
77
83
|
for (const [key, sig] of this._state) {
|
|
@@ -95,7 +101,7 @@ function useStoreKey(store, key) {
|
|
|
95
101
|
function useStore(store) {
|
|
96
102
|
return useSyncExternalStore(useCallback((callback) => {
|
|
97
103
|
const unsubscribers = [];
|
|
98
|
-
for (const [key, sig] of store.
|
|
104
|
+
for (const [key, sig] of store.entries()) {
|
|
99
105
|
unsubscribers.push(sig.subscribe(callback));
|
|
100
106
|
}
|
|
101
107
|
return () => unsubscribers.forEach((unsub) => unsub());
|
package/dist/signals.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ type Subscriber<T> = (value: T) => void;
|
|
|
9
9
|
export declare class Signal<T> {
|
|
10
10
|
private _value;
|
|
11
11
|
private _subscribers;
|
|
12
|
-
private _derivedFrom;
|
|
13
12
|
constructor(initialValue: T);
|
|
14
13
|
/** Get current value (subscribes in reactive context) */
|
|
15
14
|
get(): T;
|
|
@@ -39,6 +38,8 @@ export declare class Store<T extends Record<string, unknown>> {
|
|
|
39
38
|
get<K extends keyof T>(key: K): Signal<T[K]>;
|
|
40
39
|
/** Set value for key */
|
|
41
40
|
set<K extends keyof T>(key: K, value: T[K]): void;
|
|
41
|
+
/** Iterate over all signal entries */
|
|
42
|
+
entries(): IterableIterator<[string, Signal<unknown>]>;
|
|
42
43
|
/** Get current snapshot of all values */
|
|
43
44
|
getSnapshot(): T;
|
|
44
45
|
}
|
package/dist/signals.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../src/signals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0BAA0B;AAC1B,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAExC,iCAAiC;AACjC,qBAAa,MAAM,CAAC,CAAC;IACnB,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,YAAY,CAAiC;
|
|
1
|
+
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../src/signals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0BAA0B;AAC1B,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAExC,iCAAiC;AACjC,qBAAa,MAAM,CAAC,CAAC;IACnB,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,YAAY,CAAiC;gBAEzC,YAAY,EAAE,CAAC;IAI3B,yDAAyD;IACzD,GAAG,IAAI,CAAC;IAIR,2CAA2C;IAC3C,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAOnB,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;IACtC,OAAO,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAItD,yCAAyC;IACzC,WAAW,IAAI,CAAC;CAOjB;AAED,qBAAqB;AACrB,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAExF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ereo/state",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Ereo Team",
|
|
6
6
|
"homepage": "https://ereo.dev",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"typecheck": "tsc --noEmit"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@ereo/core": "^0.1.
|
|
36
|
+
"@ereo/core": "^0.1.24"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "^18.0.0"
|