applesauce-react 0.0.0-next-20241126194003 → 0.0.0-next-20241126195214
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.
|
@@ -6,12 +6,16 @@ export function getCurrentValue(observable) {
|
|
|
6
6
|
}
|
|
7
7
|
export function useObservable(observable) {
|
|
8
8
|
const current = observable && getCurrentValue(observable);
|
|
9
|
+
const [_count, setCount] = useState(0);
|
|
9
10
|
const [value, setValue] = useState(current);
|
|
10
11
|
useEffect(() => {
|
|
11
12
|
// Reset the state, the method passed to subscribe will NOT always be called
|
|
12
13
|
setValue(observable && getCurrentValue(observable));
|
|
13
|
-
const sub = observable?.subscribe(
|
|
14
|
+
const sub = observable?.subscribe((v) => {
|
|
15
|
+
setValue(v);
|
|
16
|
+
setCount((c) => c + 1);
|
|
17
|
+
});
|
|
14
18
|
return () => sub?.unsubscribe();
|
|
15
|
-
}, [observable, setValue]);
|
|
19
|
+
}, [observable, setValue, setCount]);
|
|
16
20
|
return current || value;
|
|
17
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-react",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20241126195214",
|
|
4
4
|
"description": "React hooks for applesauce",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"applesauce-content": "0.0.0-next-
|
|
37
|
-
"applesauce-core": "0.0.0-next-
|
|
36
|
+
"applesauce-content": "0.0.0-next-20241126195214",
|
|
37
|
+
"applesauce-core": "0.0.0-next-20241126195214",
|
|
38
38
|
"nostr-tools": "^2.10.3",
|
|
39
39
|
"react": "^18.3.1",
|
|
40
40
|
"rxjs": "^7.8.1"
|