Comparing version 4.1.0-canary.2 to 4.1.0-canary.3
@@ -12,3 +12,3 @@ import { c } from "react-compiler-runtime"; | ||
function useObservable(observable, initialValue) { | ||
const $ = c(8); | ||
const $ = c(6); | ||
if (!cache.has(observable)) { | ||
@@ -29,19 +29,13 @@ const entry = { | ||
let t0; | ||
console.count("useMemo"); | ||
$[0] !== observable ? (t0 = (onStoreChange) => { | ||
const instance = cache.get(observable); | ||
console.count("subscribe"); | ||
const subscription_0 = instance.observable.subscribe(onStoreChange); | ||
return () => { | ||
subscription_0.unsubscribe(); | ||
}; | ||
}, $[0] = observable, $[1] = t0) : t0 = $[1]; | ||
const subscribe = t0; | ||
let t1; | ||
$[0] !== observable ? (t1 = cache.get(observable), $[0] = observable, $[1] = t1) : t1 = $[1]; | ||
const instance = t1; | ||
let t2; | ||
$[2] !== instance.observable ? (t2 = { | ||
subscribe: (onStoreChange) => { | ||
console.count("subscribe"); | ||
const subscription_0 = instance.observable.subscribe(onStoreChange); | ||
return () => { | ||
subscription_0.unsubscribe(); | ||
}; | ||
} | ||
}, $[2] = instance.observable, $[3] = t2) : t2 = $[3], t0 = t2; | ||
const store = t0; | ||
let t3; | ||
$[4] !== observable ? (t3 = () => { | ||
$[2] !== observable ? (t1 = () => { | ||
const instance_0 = cache.get(observable); | ||
@@ -51,5 +45,5 @@ if (console.count("getSnapshot"), instance_0.error) | ||
return instance_0.snapshot; | ||
}, $[4] = observable, $[5] = t3) : t3 = $[5]; | ||
let t4; | ||
return $[6] !== initialValue ? (t4 = typeof initialValue > "u" ? void 0 : () => getValue(initialValue), $[6] = initialValue, $[7] = t4) : t4 = $[7], useSyncExternalStore(store.subscribe, t3, t4); | ||
}, $[2] = observable, $[3] = t1) : t1 = $[3]; | ||
let t2; | ||
return $[4] !== initialValue ? (t2 = typeof initialValue > "u" ? void 0 : () => getValue(initialValue), $[4] = initialValue, $[5] = t2) : t2 = $[5], useSyncExternalStore(subscribe, t1, t2); | ||
} | ||
@@ -56,0 +50,0 @@ function _temp4() { |
{ | ||
"name": "react-rx", | ||
"version": "4.1.0-canary.2", | ||
"version": "4.1.0-canary.3", | ||
"description": "React + RxJS = <3", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,2 +0,2 @@ | ||
import {useMemo, useSyncExternalStore} from 'react' | ||
import {useCallback, useSyncExternalStore} from 'react' | ||
import { | ||
@@ -71,19 +71,17 @@ asapScheduler, | ||
const store = useMemo(() => { | ||
console.count('useMemo') | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const instance = cache.get(observable)! | ||
return { | ||
subscribe: (onStoreChange: () => void) => { | ||
console.count('subscribe') | ||
const subscription = instance.observable.subscribe(onStoreChange) | ||
return () => { | ||
subscription.unsubscribe() | ||
} | ||
}, | ||
} | ||
}, [observable]) | ||
const subscribe = useCallback( | ||
(onStoreChange: () => void) => { | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const instance = cache.get(observable)! | ||
console.count('subscribe') | ||
const subscription = instance.observable.subscribe(onStoreChange) | ||
return () => { | ||
subscription.unsubscribe() | ||
} | ||
}, | ||
[observable], | ||
) | ||
return useSyncExternalStore<ObservedValueOf<ObservableType>>( | ||
store.subscribe, | ||
subscribe, | ||
() => { | ||
@@ -90,0 +88,0 @@ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45556
609