@livequery/react 2.0.127 → 2.0.133
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/useObservable.js
CHANGED
|
@@ -3,15 +3,15 @@ import { Observable, BehaviorSubject, tap, EMPTY } from "rxjs";
|
|
|
3
3
|
import { skip } from "rxjs/operators";
|
|
4
4
|
export function useObservable(o, default_value) {
|
|
5
5
|
const prev = useRef(o);
|
|
6
|
-
const
|
|
7
|
-
const isBehaviorSubject = typeof o == 'object' && typeof
|
|
8
|
-
const dfv = isBehaviorSubject ?
|
|
6
|
+
const source = o || EMPTY;
|
|
7
|
+
const isBehaviorSubject = typeof o == 'object' && typeof source.getValue === 'function';
|
|
8
|
+
const dfv = isBehaviorSubject ? source.getValue() : default_value;
|
|
9
9
|
const [v, s] = useState(dfv);
|
|
10
10
|
useEffect(() => {
|
|
11
11
|
const diff = prev.current !== o;
|
|
12
12
|
prev.current = o;
|
|
13
13
|
try {
|
|
14
|
-
const subscription =
|
|
14
|
+
const subscription = source.pipe(skip(isBehaviorSubject && !diff ? 1 : 0), tap(s)).subscribe();
|
|
15
15
|
return () => {
|
|
16
16
|
subscription.unsubscribe();
|
|
17
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useObservable.js","sourceRoot":"","sources":["../src/useObservable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAUtC,MAAM,UAAU,aAAa,CAAI,CAAmB,EAAE,aAAiB;IACnE,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"useObservable.js","sourceRoot":"","sources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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEtC,OAAO,CAAC,CAAA;AACZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"url": "https://github.com/livequery/react"
|
|
5
5
|
},
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "2.0.
|
|
7
|
+
"version": "2.0.133",
|
|
8
8
|
"description": "",
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/react": "^19.2.14"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@livequery/client": "^2.0.
|
|
55
|
+
"@livequery/client": "^2.0.133",
|
|
56
56
|
"rxjs": "^7.8.2",
|
|
57
57
|
"react": "^19.2.5"
|
|
58
58
|
},
|