Comparing version
@@ -28,6 +28,6 @@ import { c } from "react-compiler-runtime"; | ||
})), | ||
getSnapshot: () => { | ||
getSnapshot: (initialValue_0) => { | ||
if (state.error) | ||
throw state.error; | ||
return state.snapshot; | ||
return state.snapshot ?? getValue(initialValue_0); | ||
} | ||
@@ -49,3 +49,3 @@ }; | ||
let t2; | ||
$[4] !== instance || $[5] !== initialValue ? (t2 = () => instance.getSnapshot() ?? getValue(initialValue), $[4] = instance, $[5] = initialValue, $[6] = t2) : t2 = $[6]; | ||
$[4] !== instance || $[5] !== initialValue ? (t2 = () => instance.getSnapshot(initialValue), $[4] = instance, $[5] = initialValue, $[6] = t2) : t2 = $[6]; | ||
let t3; | ||
@@ -52,0 +52,0 @@ return $[7] !== initialValue ? (t3 = typeof initialValue > "u" ? void 0 : () => getValue(initialValue), $[7] = initialValue, $[8] = t3) : t3 = $[8], useSyncExternalStore(subscribe, t2, t3); |
{ | ||
"name": "react-rx", | ||
"version": "4.1.2-canary.11", | ||
"version": "4.1.2-canary.12", | ||
"description": "React + RxJS = <3", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -24,3 +24,3 @@ import {useCallback, useSyncExternalStore} from 'react' | ||
} | ||
getSnapshot: () => T | ||
getSnapshot: (initialValue: unknown) => T | ||
} | ||
@@ -71,11 +71,11 @@ | ||
), | ||
getSnapshot: () => { | ||
getSnapshot: (initialValue) => { | ||
if (state.error) { | ||
throw state.error | ||
} | ||
return state.snapshot | ||
return state.snapshot ?? (getValue(initialValue) as ObservedValueOf<ObservableType>) | ||
}, | ||
} | ||
// Eagerly subscribe to sync set `entry.currentValue` to what the observable returns, and keep the observable alive until the component unmounts. | ||
// Eagerly subscribe to sync set `state.snapshot` to what the observable returns, and keep the observable alive until the component unmounts. | ||
const subscription = entry.observable.subscribe() | ||
@@ -101,3 +101,3 @@ subscription.unsubscribe() | ||
() => { | ||
return instance.getSnapshot() ?? (getValue(initialValue) as ObservedValueOf<ObservableType>) | ||
return instance.getSnapshot(initialValue) | ||
}, | ||
@@ -104,0 +104,0 @@ typeof initialValue === 'undefined' |
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
46624
0.52%