react-rx 4.2.1 → 4.2.3

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![CI & Release](https://github.com/sanity-io/react-rx/actions/workflows/ci.yml/badge.svg?event=push)](https://github.com/sanity-io/react-rx/actions/workflows/ci.yml) [![npm version](https://img.shields.io/npm/v/react-rx.svg)](https://www.npmjs.com/package/react-rx)
1
+ [![CI](https://github.com/sanity-io/react-rx/actions/workflows/ci.yml/badge.svg?event=push)](https://github.com/sanity-io/react-rx/actions/workflows/ci.yml) [![npm version](https://img.shields.io/npm/v/react-rx.svg)](https://www.npmjs.com/package/react-rx)
2
2
 
3
3
  [![react-rx-some-smaller](https://user-images.githubusercontent.com/81981/194187624-9abd09da-bf03-4886-b512-78c1f22fc2de.png)](https://react-rx.dev/)
4
4
 
@@ -25,9 +25,14 @@ Although they share a lot of similarities, and reactiveComponent is built on top
25
25
 
26
26
  ---
27
27
 
28
- # Contributing and publishing new versions to npm
28
+ # Contributing and releasing new versions to npm
29
29
 
30
- Run the ["CI & Release" workflow](https://github.com/sanity-io/react-rx/actions/workflows/ci.yml).
31
- Make the default branch, `current`, should be preselected. Check "Release new version" and press "Run workflow'.
30
+ This package lives in the [`react-rx` monorepo](https://github.com/sanity-io/react-rx) and uses [Changesets](https://github.com/changesets/changesets) to manage versioning and publishing.
32
31
 
33
- Semantic release will only release on configured branches, so it is safe to run release on any branch.
32
+ When you make a change that should be released, add a changeset to your pull request:
33
+
34
+ ```sh
35
+ pnpm changeset
36
+ ```
37
+
38
+ Once pull requests with changesets are merged into the `current` branch, a "Version Packages" pull request is opened (and kept up to date) that bumps the affected package versions and updates their changelogs. Merging that pull request publishes the packages to npm through the [`Release` workflow](https://github.com/sanity-io/react-rx/actions/workflows/release.yml), which uses npm [Trusted Publishing](https://docs.npmjs.com/trusted-publishers) (OIDC).
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/useObservable.ts","../src/useObservableEvent.ts"],"sourcesContent":["import {useCallback, useMemo, useSyncExternalStore} from 'react'\nimport {\n asapScheduler,\n catchError,\n finalize,\n type Observable,\n type ObservedValueOf,\n of,\n share,\n timer,\n} from 'rxjs'\nimport {map, tap} from 'rxjs/operators'\n\nfunction getValue<T>(value: T): T extends () => infer U ? U : T {\n return (typeof value === 'function' ? (value as () => any)() : value) as T extends () => infer U\n ? U\n : T\n}\n\ninterface ObservableState<T> {\n didEmit: boolean\n snapshot?: T\n error?: unknown\n}\n\ninterface CacheRecord<T> {\n observable: Observable<void>\n state: {\n didEmit: boolean\n snapshot?: T\n error?: unknown\n }\n getSnapshot: (initialValue: unknown) => T\n}\n\nconst cache = new WeakMap<Observable<any>, CacheRecord<any>>()\n\nconst EMPTY_OBJECT = {}\n\n/** @public */\nexport interface UseObservableOptions {\n disabled?: boolean\n}\n\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>>(\n observable: ObservableType,\n initialValue: ObservedValueOf<ObservableType> | (() => ObservedValueOf<ObservableType>),\n options?: UseObservableOptions,\n): ObservedValueOf<ObservableType>\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>>(\n observable: ObservableType,\n): undefined | ObservedValueOf<ObservableType>\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>, InitialValue>(\n observable: ObservableType,\n initialValue: InitialValue | (() => InitialValue),\n options?: UseObservableOptions,\n): InitialValue | ObservedValueOf<ObservableType>\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>, InitialValue>(\n observable: ObservableType,\n initialValue?: InitialValue | (() => InitialValue),\n options: UseObservableOptions = EMPTY_OBJECT,\n): InitialValue | ObservedValueOf<ObservableType> {\n const {disabled = false} = options\n\n const instance = useMemo(() => {\n if (!cache.has(observable)) {\n // This separate object is used as a stable reference to the cache entry's snapshot and error.\n // It's used by the `getSnapshot` closure.\n const state: ObservableState<ObservedValueOf<ObservableType>> = {\n didEmit: false,\n }\n const entry: CacheRecord<ObservedValueOf<ObservableType>> = {\n state,\n observable: observable.pipe(\n map((value) => ({snapshot: value, error: undefined})),\n catchError((error) => of({snapshot: undefined, error})),\n tap(({snapshot, error}) => {\n state.didEmit = true\n state.snapshot = snapshot\n state.error = error\n }),\n // Note: any value or error emitted by the provided observable will be mapped to the cache entry's mutable state\n // and the observable is thereafter only used as a notifier to call `onStoreChange`, hence the `void` return type.\n map((value) => void value),\n // Ensure that the cache entry is deleted when the observable completes or errors.\n finalize(() => cache.delete(observable)),\n share({resetOnRefCountZero: () => timer(0, asapScheduler)}),\n ),\n getSnapshot: (initialValue) => {\n if (state.error) {\n throw state.error\n }\n return (\n state.didEmit ? state.snapshot : getValue(initialValue)\n ) as ObservedValueOf<ObservableType>\n },\n }\n\n // Eagerly subscribe to sync set `state.snapshot` to what the observable returns, and keep the observable alive until the component unmounts.\n const subscription = entry.observable.subscribe()\n subscription.unsubscribe()\n\n cache.set(observable, entry)\n }\n return cache.get(observable)!\n }, [observable])\n\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n if (disabled) {\n return () => {}\n }\n\n const subscription = instance.observable.subscribe(onStoreChange)\n return () => {\n subscription.unsubscribe()\n }\n },\n [instance.observable, disabled],\n )\n\n return useSyncExternalStore<ObservedValueOf<ObservableType>>(\n subscribe,\n () => {\n return instance.getSnapshot(initialValue)\n },\n typeof initialValue === 'undefined'\n ? undefined\n : () => getValue(initialValue) as ObservedValueOf<ObservableType>,\n )\n}\n","import {observableCallback} from 'observable-callback'\nimport {useEffect, useState} from 'react'\nimport {type Observable} from 'rxjs'\nimport {useEffectEvent} from 'use-effect-event'\n\n/** @public */\nexport function useObservableEvent<T, U>(\n handleEvent: (arg: Observable<T>) => Observable<U>,\n): (arg: T) => void {\n const [[calls$, call]] = useState(() => observableCallback<T>())\n\n const onEvent = useEffectEvent((observable: Observable<T>) => handleEvent(observable))\n\n useEffect(() => {\n const subscription = calls$.pipe((observable) => onEvent(observable)).subscribe()\n return () => subscription.unsubscribe()\n }, [calls$])\n\n return call\n}\n"],"names":["getValue","value","cache","WeakMap","EMPTY_OBJECT","useObservable","observable","initialValue","t0","$","_c","options","undefined","disabled","t1","has","state","didEmit","entry","pipe","map","_temp","catchError","_temp2","tap","t2","snapshot","error","error_0","_temp3","finalize","delete","share","resetOnRefCountZero","_temp4","getSnapshot","initialValue_0","subscribe","unsubscribe","set","get","instance","t3","onStoreChange","_temp5","subscription_0","subscription","t4","t5","useSyncExternalStore","timer","asapScheduler","value_0","of","useObservableEvent","handleEvent","useState","calls$","call","onEvent","useEffectEvent","observable_0","useEffect","observableCallback"],"mappings":";;;;AAaA,SAASA,SAAYC,OAA2C;AAC9D,SAAQ,OAAOA,SAAU,aAAcA,MAAAA,IAAwBA;AAGjE;AAkBA,MAAMC,QAAQ,oBAAIC,WAEZC,eAAe,CAAA;AAwBd,SAAAC,cAAAC,YAAAC,cAAAC,IAAA;AAAA,QAAAC,IAAAC,qBAAAA,EAAA,EAAA,GAGLC,UAAAH,OAA4CI,SAAAR,eAA5CI,IAEA;AAAA,IAAAK,UAAAC;AAAAA,EAAAA,IAA2BH,SAApBE,WAAAC,OAAgBF,cAAhBE;AAAgB,MAAA,CAGhBZ,MAAAa,IAAUT,UAAU,GAAC;AAGxB,UAAAU,QAAA;AAAA,MAAAC,SAAA;AAAA,IAAA,GAGAC,QAAA;AAAA,MAAAF;AAAAA,MAAAV,YAEcA,WAAUa,KACpBC,UAAAA,IAAAC,OAAoD,GACpDC,KAAAA,WAAAC,MAAsD,GACtDC,cAAAC,CAAAA,QAAA;AAAK,cAAA;AAAA,UAAAC;AAAAA,UAAAC,OAAAC;AAAAA,QAAAA,IAAAH;AACHT,cAAKC,UAAA,IACLD,MAAKU,WAAYA,UACjBV,MAAKW,QAASA;AAAAA,MAAK,CACpB,GAGDP,UAAAA,IAAAS,MAAyB,GAEzBC,KAAAA,SAAA,MAAe5B,MAAA6B,OAAazB,UAAU,CAAC,GACvC0B,WAAA;AAAA,QAAAC,qBAAAC;AAAAA,MA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useMemo, useSyncExternalStore} from 'react'\nimport {\n asapScheduler,\n catchError,\n finalize,\n type Observable,\n type ObservedValueOf,\n of,\n share,\n timer,\n} from 'rxjs'\nimport {map, tap} from 'rxjs/operators'\n\nfunction getValue<T>(value: T): T extends () => infer U ? U : T {\n return (typeof value === 'function' ? (value as () => any)() : value) as T extends () => infer U\n ? U\n : T\n}\n\ninterface ObservableState<T> {\n didEmit: boolean\n snapshot?: T\n error?: unknown\n}\n\ninterface CacheRecord<T> {\n observable: Observable<void>\n state: {\n didEmit: boolean\n snapshot?: T\n error?: unknown\n }\n getSnapshot: (initialValue: unknown) => T\n}\n\nconst cache = new WeakMap<Observable<any>, CacheRecord<any>>()\n\nconst EMPTY_OBJECT = {}\n\n/** @public */\nexport interface UseObservableOptions {\n disabled?: boolean\n}\n\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>>(\n observable: ObservableType,\n initialValue: ObservedValueOf<ObservableType> | (() => ObservedValueOf<ObservableType>),\n options?: UseObservableOptions,\n): ObservedValueOf<ObservableType>\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>>(\n observable: ObservableType,\n): undefined | ObservedValueOf<ObservableType>\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>, InitialValue>(\n observable: ObservableType,\n initialValue: InitialValue | (() => InitialValue),\n options?: UseObservableOptions,\n): InitialValue | ObservedValueOf<ObservableType>\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>, InitialValue>(\n observable: ObservableType,\n initialValue?: InitialValue | (() => InitialValue),\n options: UseObservableOptions = EMPTY_OBJECT,\n): InitialValue | ObservedValueOf<ObservableType> {\n const {disabled = false} = options\n\n const instance = useMemo(() => {\n if (!cache.has(observable)) {\n // This separate object is used as a stable reference to the cache entry's snapshot and error.\n // It's used by the `getSnapshot` closure.\n const state: ObservableState<ObservedValueOf<ObservableType>> = {\n didEmit: false,\n }\n const entry: CacheRecord<ObservedValueOf<ObservableType>> = {\n state,\n observable: observable.pipe(\n map((value) => ({snapshot: value, error: undefined})),\n catchError((error) => of({snapshot: undefined, error})),\n tap(({snapshot, error}) => {\n state.didEmit = true\n state.snapshot = snapshot\n state.error = error\n }),\n // Note: any value or error emitted by the provided observable will be mapped to the cache entry's mutable state\n // and the observable is thereafter only used as a notifier to call `onStoreChange`, hence the `void` return type.\n map((value) => void value),\n // Ensure that the cache entry is deleted when the observable completes or errors.\n finalize(() => cache.delete(observable)),\n share({resetOnRefCountZero: () => timer(0, asapScheduler)}),\n ),\n getSnapshot: (initialValue) => {\n if (state.error) {\n throw state.error\n }\n return (\n state.didEmit ? state.snapshot : getValue(initialValue)\n ) as ObservedValueOf<ObservableType>\n },\n }\n\n // Eagerly subscribe to sync set `state.snapshot` to what the observable returns, and keep the observable alive until the component unmounts.\n const subscription = entry.observable.subscribe()\n subscription.unsubscribe()\n\n cache.set(observable, entry)\n }\n return cache.get(observable)!\n }, [observable])\n\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n if (disabled) {\n return () => {}\n }\n\n const subscription = instance.observable.subscribe(onStoreChange)\n return () => {\n subscription.unsubscribe()\n }\n },\n [instance.observable, disabled],\n )\n\n return useSyncExternalStore<ObservedValueOf<ObservableType>>(\n subscribe,\n () => {\n return instance.getSnapshot(initialValue)\n },\n typeof initialValue === 'undefined'\n ? undefined\n : () => getValue(initialValue) as ObservedValueOf<ObservableType>,\n )\n}\n","import {observableCallback} from 'observable-callback'\nimport {useEffect, useState} from 'react'\nimport {type Observable} from 'rxjs'\nimport {useEffectEvent} from 'use-effect-event'\n\n/** @public */\nexport function useObservableEvent<T, U>(\n handleEvent: (arg: Observable<T>) => Observable<U>,\n): (arg: T) => void {\n const [[calls$, call]] = useState(() => observableCallback<T>())\n\n const onEvent = useEffectEvent((observable: Observable<T>) => handleEvent(observable))\n\n useEffect(() => {\n const subscription = calls$.pipe((observable) => onEvent(observable)).subscribe()\n return () => subscription.unsubscribe()\n }, [calls$])\n\n return call\n}\n"],"names":["getValue","value","cache","WeakMap","EMPTY_OBJECT","useObservable","observable","initialValue","t0","$","_c","options","undefined","disabled","t1","has","state","didEmit","entry","pipe","map","_temp","catchError","_temp2","tap","t2","snapshot","error","error_0","_temp3","finalize","delete","share","resetOnRefCountZero","_temp4","getSnapshot","initialValue_0","subscribe","unsubscribe","set","get","instance","t3","onStoreChange","_temp5","subscription_0","subscription","t4","t5","useSyncExternalStore","timer","asapScheduler","value_0","of","useObservableEvent","handleEvent","useState","calls$","call","onEvent","useEffectEvent","observable_0","useEffect","observableCallback"],"mappings":";;;;AAaA,SAASA,SAAYC,OAA2C;AAC9D,SAAQ,OAAOA,SAAU,aAAcA,MAAAA,IAAwBA;AAGjE;AAkBA,MAAMC,QAAQ,oBAAIC,WAEZC,eAAe,CAAA;AAwBd,SAAAC,cAAAC,YAAAC,cAAAC,IAAA;AAAA,QAAAC,IAAAC,qBAAAA,EAAA,EAAA,GAGLC,UAAAH,OAAAI,SAAAR,eAAAI,IAEA;AAAA,IAAAK,UAAAC;AAAAA,EAAAA,IAA2BH,SAApBE,WAAAC,OAAAF,SAAA,KAAAE;AAGL,MAAI,CAACZ,MAAKa,IAAKT,UAAU,GAAC;AAGxB,UAAAU,QAAgE;AAAA,MAAAC,SACrD;AAAA,IAAA,GAEXC,QAA4D;AAAA,MAAAF;AAAAA,MAAAV,YAE9CA,WAAUa,KACpBC,UAAAA,IAAIC,OAAgD,GACpDC,KAAAA,WAAWC,MAA2C,GACtDC,cAAIC,CAAAA,QAAA;AAAC,cAAA;AAAA,UAAAC;AAAAA,UAAAC,OAAAC;AAAAA,QAAAA,IAAAH;AACHT,cAAKC,UAAW,IAChBD,MAAKU,WAAYA,UACjBV,MAAKW,QAASA;AAAAA,MAAH,CACZ,GAGDP,UAAAA,IAAIS,MAAqB,GAEzBC,KAAAA,SAAS,MAAM5B,MAAK6B,OAAQzB,UAAU,CAAC,GACvC0B,WAAM;AAAA,QAAAC,qBAAsBC;AAAAA,MAAAA,CAA8B,CAC5D;AAAA,MAACC,aACYC,CAAAA,mBAAA;AACX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4B;AA1B5B,SAAA7B,OAAAI,OAAA;AAAA,SAkByB0B,QAAG;AAAA,IAAA3B,UAAWd;AAAAA,IAASe;AAAAA,EAAAA,CAAQ;AAAC;AAlBzD,SAAAN,QAAApB,OAAA;AAAA,SAiBmB;AAAA,IAAAyB,UAAWzB;AAAAA,IAAK0B,OAASf;AAAAA,EAAAA;AAAU;ACxEtD,SAAA0C,mBAAAC,aAAA;AAAA,QAAA9C,IAAAC,qBAAAA,EAAA,CAAA,GAGL,CAAAF,EAAA,IAAyBgD,MAAAA,SAASnC,KAA6B,GAAxD,CAAAoC,QAAAC,IAAA,IAAAlD;AAAc,MAAAM;AAAAL,WAAA8C,eAEUzC,KAAAR,CAAAA,eAA+BiD,YAAYjD,UAAU,GAACG,OAAA8C,aAAA9C,OAAAK,MAAAA,KAAAL,EAAA,CAAA;AAArF,QAAAkD,UAAgBC,eAAAA,eAAe9C,EAAsD;AAAC,MAAAW;AAAAhB,IAAA,CAAA,MAAAgD,UAAAhD,SAAAkD,WAE5ElC,KAAAA,MAAA;AACR,UAAAqB,eAAqBW,OAAMtC,KAAM0C,CAAAA,iBAAgBF,QAAQrD,YAAU,CAAC,EAAC+B,UAAAA;AAAY,WAC1E,MAAMS,aAAYR,YAAAA;AAAAA,EAAc,GACxC7B,OAAAgD,QAAAhD,OAAAkD,SAAAlD,OAAAgB,MAAAA,KAAAhB,EAAA,CAAA;AAAA,MAAAiC;AAAA,SAAAjC,SAAAgD,UAAEf,KAAA,CAACe,MAAM,GAAChD,OAAAgD,QAAAhD,OAAAiC,MAAAA,KAAAjC,EAAA,CAAA,GAHXqD,gBAAUrC,IAGPiB,EAAQ,GAEJgB;AAAI;AAZN,SAAArC,QAAA;AAAA,SAGmC0C,sCAAAA;AAAuB;;;"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/useObservable.ts","../src/useObservableEvent.ts"],"sourcesContent":["import {useCallback, useMemo, useSyncExternalStore} from 'react'\nimport {\n asapScheduler,\n catchError,\n finalize,\n type Observable,\n type ObservedValueOf,\n of,\n share,\n timer,\n} from 'rxjs'\nimport {map, tap} from 'rxjs/operators'\n\nfunction getValue<T>(value: T): T extends () => infer U ? U : T {\n return (typeof value === 'function' ? (value as () => any)() : value) as T extends () => infer U\n ? U\n : T\n}\n\ninterface ObservableState<T> {\n didEmit: boolean\n snapshot?: T\n error?: unknown\n}\n\ninterface CacheRecord<T> {\n observable: Observable<void>\n state: {\n didEmit: boolean\n snapshot?: T\n error?: unknown\n }\n getSnapshot: (initialValue: unknown) => T\n}\n\nconst cache = new WeakMap<Observable<any>, CacheRecord<any>>()\n\nconst EMPTY_OBJECT = {}\n\n/** @public */\nexport interface UseObservableOptions {\n disabled?: boolean\n}\n\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>>(\n observable: ObservableType,\n initialValue: ObservedValueOf<ObservableType> | (() => ObservedValueOf<ObservableType>),\n options?: UseObservableOptions,\n): ObservedValueOf<ObservableType>\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>>(\n observable: ObservableType,\n): undefined | ObservedValueOf<ObservableType>\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>, InitialValue>(\n observable: ObservableType,\n initialValue: InitialValue | (() => InitialValue),\n options?: UseObservableOptions,\n): InitialValue | ObservedValueOf<ObservableType>\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>, InitialValue>(\n observable: ObservableType,\n initialValue?: InitialValue | (() => InitialValue),\n options: UseObservableOptions = EMPTY_OBJECT,\n): InitialValue | ObservedValueOf<ObservableType> {\n const {disabled = false} = options\n\n const instance = useMemo(() => {\n if (!cache.has(observable)) {\n // This separate object is used as a stable reference to the cache entry's snapshot and error.\n // It's used by the `getSnapshot` closure.\n const state: ObservableState<ObservedValueOf<ObservableType>> = {\n didEmit: false,\n }\n const entry: CacheRecord<ObservedValueOf<ObservableType>> = {\n state,\n observable: observable.pipe(\n map((value) => ({snapshot: value, error: undefined})),\n catchError((error) => of({snapshot: undefined, error})),\n tap(({snapshot, error}) => {\n state.didEmit = true\n state.snapshot = snapshot\n state.error = error\n }),\n // Note: any value or error emitted by the provided observable will be mapped to the cache entry's mutable state\n // and the observable is thereafter only used as a notifier to call `onStoreChange`, hence the `void` return type.\n map((value) => void value),\n // Ensure that the cache entry is deleted when the observable completes or errors.\n finalize(() => cache.delete(observable)),\n share({resetOnRefCountZero: () => timer(0, asapScheduler)}),\n ),\n getSnapshot: (initialValue) => {\n if (state.error) {\n throw state.error\n }\n return (\n state.didEmit ? state.snapshot : getValue(initialValue)\n ) as ObservedValueOf<ObservableType>\n },\n }\n\n // Eagerly subscribe to sync set `state.snapshot` to what the observable returns, and keep the observable alive until the component unmounts.\n const subscription = entry.observable.subscribe()\n subscription.unsubscribe()\n\n cache.set(observable, entry)\n }\n return cache.get(observable)!\n }, [observable])\n\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n if (disabled) {\n return () => {}\n }\n\n const subscription = instance.observable.subscribe(onStoreChange)\n return () => {\n subscription.unsubscribe()\n }\n },\n [instance.observable, disabled],\n )\n\n return useSyncExternalStore<ObservedValueOf<ObservableType>>(\n subscribe,\n () => {\n return instance.getSnapshot(initialValue)\n },\n typeof initialValue === 'undefined'\n ? undefined\n : () => getValue(initialValue) as ObservedValueOf<ObservableType>,\n )\n}\n","import {observableCallback} from 'observable-callback'\nimport {useEffect, useState} from 'react'\nimport {type Observable} from 'rxjs'\nimport {useEffectEvent} from 'use-effect-event'\n\n/** @public */\nexport function useObservableEvent<T, U>(\n handleEvent: (arg: Observable<T>) => Observable<U>,\n): (arg: T) => void {\n const [[calls$, call]] = useState(() => observableCallback<T>())\n\n const onEvent = useEffectEvent((observable: Observable<T>) => handleEvent(observable))\n\n useEffect(() => {\n const subscription = calls$.pipe((observable) => onEvent(observable)).subscribe()\n return () => subscription.unsubscribe()\n }, [calls$])\n\n return call\n}\n"],"names":["getValue","value","cache","WeakMap","EMPTY_OBJECT","useObservable","observable","initialValue","t0","$","_c","options","undefined","disabled","t1","has","state","didEmit","entry","pipe","map","_temp","catchError","_temp2","tap","t2","snapshot","error","error_0","_temp3","finalize","delete","share","resetOnRefCountZero","_temp4","getSnapshot","initialValue_0","subscribe","unsubscribe","set","get","instance","t3","onStoreChange","_temp5","subscription_0","subscription","t4","t5","useSyncExternalStore","timer","asapScheduler","value_0","of","useObservableEvent","handleEvent","useState","calls$","call","onEvent","useEffectEvent","observable_0","useEffect","observableCallback"],"mappings":";;;;;;;AAaA,SAASA,SAAYC,OAA2C;AAC9D,SAAQ,OAAOA,SAAU,aAAcA,MAAAA,IAAwBA;AAGjE;AAkBA,MAAMC,QAAQ,oBAAIC,WAEZC,eAAe,CAAA;AAwBd,SAAAC,cAAAC,YAAAC,cAAAC,IAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA,GAGLC,UAAAH,OAA4CI,SAAAR,eAA5CI,IAEA;AAAA,IAAAK,UAAAC;AAAAA,EAAAA,IAA2BH,SAApBE,WAAAC,OAAgBF,cAAhBE;AAAgB,MAAA,CAGhBZ,MAAAa,IAAUT,UAAU,GAAC;AAGxB,UAAAU,QAAA;AAAA,MAAAC,SAAA;AAAA,IAAA,GAGAC,QAAA;AAAA,MAAAF;AAAAA,MAAAV,YAEcA,WAAUa,KACpBC,IAAAC,OAAoD,GACpDC,WAAAC,MAAsD,GACtDC,IAAAC,CAAAA,QAAA;AAAK,cAAA;AAAA,UAAAC;AAAAA,UAAAC,OAAAC;AAAAA,QAAAA,IAAAH;AACHT,cAAKC,UAAA,IACLD,MAAKU,WAAYA,UACjBV,MAAKW,QAASA;AAAAA,MAAK,CACpB,GAGDP,IAAAS,MAAyB,GAEzBC,SAAA,MAAe5B,MAAA6B,OAAazB,UAAU,CAAC,GACvC0B,MAAA;AAAA,QAAAC,qBAAAC;AAAAA,MAAAA,CAA0D,CAC5D;AAAA,MAACC,aAAAC,CAAAA,mBAAA;AAAA,YAEKpB,MAAKW;AAAA,gBACDX,MAAKW;AAAA,eAGXX,MAAKC,UAAWD,M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d;AAAAA,IAAAe;AAAAA,EAAAA,CAA+B;AAAC;AAlBzD,SAAAN,QAAApB,OAAA;AAAA,SAAA;AAAA,IAAAyB,UAiB8BzB;AAAAA,IAAK0B,OAAAf;AAAAA,EAAAA;AAAA;ACxEnC,SAAA0C,mBAAAC,aAAA;AAAA,QAAA9C,IAAAC,EAAA,CAAA,GAGL,CAAAF,EAAA,IAAyBgD,SAAAnC,KAAsC,GAAxD,CAAAoC,QAAAC,IAAA,IAAAlD;AAAc,MAAAM;AAAAL,WAAA8C,eAEUzC,KAAAR,CAAAA,eAA+BiD,YAAYjD,UAAU,GAACG,OAAA8C,aAAA9C,OAAAK,MAAAA,KAAAL,EAAA,CAAA;AAArF,QAAAkD,UAAgBC,eAAe9C,EAAsD;AAAC,MAAAW;AAAAhB,IAAA,CAAA,MAAAgD,UAAAhD,SAAAkD,WAE5ElC,KAAAA,MAAA;AACR,UAAAqB,eAAqBW,OAAMtC,KAAA0C,CAAAA,iBAAsBF,QAAQrD,YAAU,CAAC,EAAC+B,UAAAA;AAAY,WAAA,MACpES,aAAYR,YAAAA;AAAAA,EAAc,GACxC7B,OAAAgD,QAAAhD,OAAAkD,SAAAlD,OAAAgB,MAAAA,KAAAhB,EAAA,CAAA;AAAA,MAAAiC;AAAA,SAAAjC,SAAAgD,UAAEf,MAACe,MAAM,GAAChD,OAAAgD,QAAAhD,OAAAiC,MAAAA,KAAAjC,EAAA,CAAA,GAHXqD,UAAUrC,IAGPiB,EAAQ,GAEJgB;AAAI;AAZN,SAAArC,QAAA;AAAA,SAGmC0C,mBAAAA;AAAuB;"}
1
+ {"version":3,"file":"index.js","sources":["../src/useObservable.ts","../src/useObservableEvent.ts"],"sourcesContent":["import {useCallback, useMemo, useSyncExternalStore} from 'react'\nimport {\n asapScheduler,\n catchError,\n finalize,\n type Observable,\n type ObservedValueOf,\n of,\n share,\n timer,\n} from 'rxjs'\nimport {map, tap} from 'rxjs/operators'\n\nfunction getValue<T>(value: T): T extends () => infer U ? U : T {\n return (typeof value === 'function' ? (value as () => any)() : value) as T extends () => infer U\n ? U\n : T\n}\n\ninterface ObservableState<T> {\n didEmit: boolean\n snapshot?: T\n error?: unknown\n}\n\ninterface CacheRecord<T> {\n observable: Observable<void>\n state: {\n didEmit: boolean\n snapshot?: T\n error?: unknown\n }\n getSnapshot: (initialValue: unknown) => T\n}\n\nconst cache = new WeakMap<Observable<any>, CacheRecord<any>>()\n\nconst EMPTY_OBJECT = {}\n\n/** @public */\nexport interface UseObservableOptions {\n disabled?: boolean\n}\n\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>>(\n observable: ObservableType,\n initialValue: ObservedValueOf<ObservableType> | (() => ObservedValueOf<ObservableType>),\n options?: UseObservableOptions,\n): ObservedValueOf<ObservableType>\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>>(\n observable: ObservableType,\n): undefined | ObservedValueOf<ObservableType>\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>, InitialValue>(\n observable: ObservableType,\n initialValue: InitialValue | (() => InitialValue),\n options?: UseObservableOptions,\n): InitialValue | ObservedValueOf<ObservableType>\n/** @public */\nexport function useObservable<ObservableType extends Observable<any>, InitialValue>(\n observable: ObservableType,\n initialValue?: InitialValue | (() => InitialValue),\n options: UseObservableOptions = EMPTY_OBJECT,\n): InitialValue | ObservedValueOf<ObservableType> {\n const {disabled = false} = options\n\n const instance = useMemo(() => {\n if (!cache.has(observable)) {\n // This separate object is used as a stable reference to the cache entry's snapshot and error.\n // It's used by the `getSnapshot` closure.\n const state: ObservableState<ObservedValueOf<ObservableType>> = {\n didEmit: false,\n }\n const entry: CacheRecord<ObservedValueOf<ObservableType>> = {\n state,\n observable: observable.pipe(\n map((value) => ({snapshot: value, error: undefined})),\n catchError((error) => of({snapshot: undefined, error})),\n tap(({snapshot, error}) => {\n state.didEmit = true\n state.snapshot = snapshot\n state.error = error\n }),\n // Note: any value or error emitted by the provided observable will be mapped to the cache entry's mutable state\n // and the observable is thereafter only used as a notifier to call `onStoreChange`, hence the `void` return type.\n map((value) => void value),\n // Ensure that the cache entry is deleted when the observable completes or errors.\n finalize(() => cache.delete(observable)),\n share({resetOnRefCountZero: () => timer(0, asapScheduler)}),\n ),\n getSnapshot: (initialValue) => {\n if (state.error) {\n throw state.error\n }\n return (\n state.didEmit ? state.snapshot : getValue(initialValue)\n ) as ObservedValueOf<ObservableType>\n },\n }\n\n // Eagerly subscribe to sync set `state.snapshot` to what the observable returns, and keep the observable alive until the component unmounts.\n const subscription = entry.observable.subscribe()\n subscription.unsubscribe()\n\n cache.set(observable, entry)\n }\n return cache.get(observable)!\n }, [observable])\n\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n if (disabled) {\n return () => {}\n }\n\n const subscription = instance.observable.subscribe(onStoreChange)\n return () => {\n subscription.unsubscribe()\n }\n },\n [instance.observable, disabled],\n )\n\n return useSyncExternalStore<ObservedValueOf<ObservableType>>(\n subscribe,\n () => {\n return instance.getSnapshot(initialValue)\n },\n typeof initialValue === 'undefined'\n ? undefined\n : () => getValue(initialValue) as ObservedValueOf<ObservableType>,\n )\n}\n","import {observableCallback} from 'observable-callback'\nimport {useEffect, useState} from 'react'\nimport {type Observable} from 'rxjs'\nimport {useEffectEvent} from 'use-effect-event'\n\n/** @public */\nexport function useObservableEvent<T, U>(\n handleEvent: (arg: Observable<T>) => Observable<U>,\n): (arg: T) => void {\n const [[calls$, call]] = useState(() => observableCallback<T>())\n\n const onEvent = useEffectEvent((observable: Observable<T>) => handleEvent(observable))\n\n useEffect(() => {\n const subscription = calls$.pipe((observable) => onEvent(observable)).subscribe()\n return () => subscription.unsubscribe()\n }, [calls$])\n\n return call\n}\n"],"names":["getValue","value","cache","WeakMap","EMPTY_OBJECT","useObservable","observable","initialValue","t0","$","_c","options","undefined","disabled","t1","has","state","didEmit","entry","pipe","map","_temp","catchError","_temp2","tap","t2","snapshot","error","error_0","_temp3","finalize","delete","share","resetOnRefCountZero","_temp4","getSnapshot","initialValue_0","subscribe","unsubscribe","set","get","instance","t3","onStoreChange","_temp5","subscription_0","subscription","t4","t5","useSyncExternalStore","timer","asapScheduler","value_0","of","useObservableEvent","handleEvent","useState","calls$","call","onEvent","useEffectEvent","observable_0","useEffect","observableCallback"],"mappings":";;;;;;;AAaA,SAASA,SAAYC,OAA2C;AAC9D,SAAQ,OAAOA,SAAU,aAAcA,MAAAA,IAAwBA;AAGjE;AAkBA,MAAMC,QAAQ,oBAAIC,WAEZC,eAAe,CAAA;AAwBd,SAAAC,cAAAC,YAAAC,cAAAC,IAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA,GAGLC,UAAAH,OAAAI,SAAAR,eAAAI,IAEA;AAAA,IAAAK,UAAAC;AAAAA,EAAAA,IAA2BH,SAApBE,WAAAC,OAAAF,SAAA,KAAAE;AAGL,MAAI,CAACZ,MAAKa,IAAKT,UAAU,GAAC;AAGxB,UAAAU,QAAgE;AAAA,MAAAC,SACrD;AAAA,IAAA,GAEXC,QAA4D;AAAA,MAAAF;AAAAA,MAAAV,YAE9CA,WAAUa,KACpBC,IAAIC,OAAgD,GACpDC,WAAWC,MAA2C,GACtDC,IAAIC,CAAAA,QAAA;AAAC,cAAA;AAAA,UAAAC;AAAAA,UAAAC,OAAAC;AAAAA,QAAAA,IAAAH;AACHT,cAAKC,UAAW,IAChBD,MAAKU,WAAYA,UACjBV,MAAKW,QAASA;AAAAA,MAAH,CACZ,GAGDP,IAAIS,MAAqB,GAEzBC,SAAS,MAAM5B,MAAK6B,OAAQzB,UAAU,CAAC,GACvC0B,MAAM;AAAA,QAAAC,qBAAsBC;AAAAA,MAAAA,CAA8B,CAC5D;AAAA,MAACC,aACYC,CAAAA,mBAAA;AACX,YAAIpB,MAAKW;AACP,gBAAMX,MAAKW;AACZ,eAECX,MAAKC,UAAWD,MAAKU,WAAY1B,SAASO,cAAY;AAAA,MAAC;AAAA,IAAA;AAMxCW,UAAKZ,WAAW+B,YACzBC,eAEZpC,MAAKqC,IAAKjC,YAAYY,KAAK;AAAA,EAAC;AAC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A;AAAU;ACxEtD,SAAA0C,mBAAAC,aAAA;AAAA,QAAA9C,IAAAC,EAAA,CAAA,GAGL,CAAAF,EAAA,IAAyBgD,SAASnC,KAA6B,GAAxD,CAAAoC,QAAAC,IAAA,IAAAlD;AAAc,MAAAM;AAAAL,WAAA8C,eAEUzC,KAAAR,CAAAA,eAA+BiD,YAAYjD,UAAU,GAACG,OAAA8C,aAAA9C,OAAAK,MAAAA,KAAAL,EAAA,CAAA;AAArF,QAAAkD,UAAgBC,eAAe9C,EAAsD;AAAC,MAAAW;AAAAhB,IAAA,CAAA,MAAAgD,UAAAhD,SAAAkD,WAE5ElC,KAAAA,MAAA;AACR,UAAAqB,eAAqBW,OAAMtC,KAAM0C,CAAAA,iBAAgBF,QAAQrD,YAAU,CAAC,EAAC+B,UAAAA;AAAY,WAC1E,MAAMS,aAAYR,YAAAA;AAAAA,EAAc,GACxC7B,OAAAgD,QAAAhD,OAAAkD,SAAAlD,OAAAgB,MAAAA,KAAAhB,EAAA,CAAA;AAAA,MAAAiC;AAAA,SAAAjC,SAAAgD,UAAEf,KAAA,CAACe,MAAM,GAAChD,OAAAgD,QAAAhD,OAAAiC,MAAAA,KAAAjC,EAAA,CAAA,GAHXqD,UAAUrC,IAGPiB,EAAQ,GAEJgB;AAAI;AAZN,SAAArC,QAAA;AAAA,SAGmC0C,mBAAAA;AAAuB;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-rx",
3
- "version": "4.2.1",
3
+ "version": "4.2.3",
4
4
  "description": "React + RxJS = <3",
5
5
  "keywords": [
6
6
  "action",
@@ -37,7 +37,8 @@
37
37
  },
38
38
  "repository": {
39
39
  "type": "git",
40
- "url": "git+https://github.com/sanity-io/react-rx.git"
40
+ "url": "git+https://github.com/sanity-io/react-rx.git",
41
+ "directory": "packages/react-rx"
41
42
  },
42
43
  "license": "MIT",
43
44
  "author": "Sanity.io <hello@sanity.io>",
@@ -62,56 +63,37 @@
62
63
  "dist",
63
64
  "src"
64
65
  ],
65
- "scripts": {
66
- "build": "pkg build --strict --clean --check",
67
- "dev": "pnpm --filter 'react-rx-website' dev",
68
- "format": "prettier --cache --write .",
69
- "lint": "eslint --cache .",
70
- "prepublishOnly": "pnpm build",
71
- "test": "vitest run --typecheck",
72
- "watch": "pnpm build -- --watch"
73
- },
74
66
  "browserslist": "extends @sanity/browserslist-config",
75
- "prettier": "@sanity/prettier-config",
76
67
  "dependencies": {
77
68
  "observable-callback": "^1.0.3",
78
- "react-compiler-runtime": "19.1.0-rc.3",
69
+ "react-compiler-runtime": "1.0.0",
79
70
  "use-effect-event": "^2.0.3"
80
71
  },
81
72
  "devDependencies": {
82
73
  "@sanity/browserslist-config": "^1.0.5",
83
- "@sanity/pkg-utils": "^8.1.14",
84
- "@sanity/prettier-config": "^1.0.6",
85
- "@sanity/semantic-release-preset": "^5.0.0",
74
+ "@sanity/pkg-utils": "^8.1.23",
86
75
  "@testing-library/dom": "^10.4.1",
87
76
  "@testing-library/react": "^16.3.0",
88
77
  "@types/node": "^24.3.0",
89
- "@types/react": "^19.1.12",
90
- "@types/react-dom": "^19.1.9",
91
- "@typescript-eslint/eslint-plugin": "^8.41.0",
92
- "@typescript-eslint/parser": "^8.41.0",
78
+ "@types/react": "^19.2.7",
79
+ "@types/react-dom": "^19.2.3",
93
80
  "@vitejs/plugin-react": "^5.0.3",
94
- "babel-plugin-react-compiler": "19.1.0-rc.3",
95
- "eslint": "^9.34.0",
96
- "eslint-config-prettier": "^10.1.8",
97
- "eslint-plugin-react": "^7.37.5",
98
- "eslint-plugin-react-hooks": "6.0.0-rc.2",
99
- "eslint-plugin-react-hooks-with-use-effect-event": "npm:eslint-plugin-react-hooks@0.0.0-experimental-d415fd3e-20250919",
100
- "eslint-plugin-simple-import-sort": "^12.1.1",
81
+ "babel-plugin-react-compiler": "1.0.0",
101
82
  "jsdom": "^26.1.0",
102
- "prettier": "^3.6.2",
103
- "react": "^19.1.1",
104
- "react-dom": "^19.1.1",
105
- "react-test-renderer": "^19.1.1",
83
+ "react": "^19.2.1",
84
+ "react-dom": "^19.2.1",
85
+ "react-test-renderer": "^19.2.1",
106
86
  "rxjs": "^7.8.2",
107
- "semantic-release": "^24.2.7",
108
87
  "typescript": "5.9.2",
109
- "typescript-eslint": "^8.41.0",
110
88
  "vitest": "^3.2.4"
111
89
  },
112
90
  "peerDependencies": {
113
91
  "react": "^18.3 || >=19.0.0-0",
114
92
  "rxjs": "^7"
115
93
  },
116
- "packageManager": "pnpm@9.15.9"
117
- }
94
+ "scripts": {
95
+ "build": "pkg build --strict --clean --check",
96
+ "test": "vitest run --typecheck",
97
+ "watch": "pnpm build -- --watch"
98
+ }
99
+ }