🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

react-rx

Package Overview
Dependencies
Maintainers
62
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-rx - npm Package Compare versions

Comparing version

to
4.1.2-canary.1

112

dist/index.js

@@ -1,3 +0,2 @@

import { c } from "react-compiler-runtime";
import { useState, useEffect, useSyncExternalStore } from "react";
import { useState, useMemo, useEffect, useSyncExternalStore } from "react";
import { catchError, of, finalize, share, timer, asapScheduler } from "rxjs";

@@ -12,71 +11,54 @@ import { map, tap } from "rxjs/operators";

function useObservable(observable, initialValue) {
const $ = c(18);
let t0;
$[0] !== initialValue ? (t0 = () => () => getValue(initialValue), $[0] = initialValue, $[1] = t0) : t0 = $[1];
const [getInitialValue] = useState(t0);
let t1;
if (!cache.has(observable)) {
const entry = {
snapshot: getInitialValue()
const [getInitialValue] = useState(
() => () => getValue(initialValue)
), store = useMemo(() => {
if (!cache.has(observable)) {
const entry = {
snapshot: getInitialValue()
};
entry.observable = observable.pipe(
map((value) => ({ snapshot: value, error: void 0 })),
catchError((error) => of({ snapshot: void 0, error })),
tap(({ snapshot, error }) => {
entry.snapshot = snapshot, entry.error = error;
}),
// Note: any value or error emitted by the provided observable will be mapped to the cache entry's mutable state
// and the observable is thereafter only used as a notifier to call `onStoreChange`, hence the `void` return type.
map((value) => {
}),
// Ensure that the cache entry is deleted when the observable completes or errors.
finalize(() => cache.delete(observable)),
share({ resetOnRefCountZero: () => timer(0, asapScheduler) })
), entry.observable.subscribe().unsubscribe(), cache.set(observable, entry);
}
const instance = cache.get(observable);
return {
subscribe: (onStoreChange) => {
const subscription = instance.observable.subscribe(onStoreChange);
return () => {
subscription.unsubscribe();
};
},
getSnapshot: () => {
if (instance.error)
throw instance.error;
return instance.snapshot;
}
};
entry.observable = observable.pipe(map((value) => ({
snapshot: value,
error: void 0
})), catchError((error) => of({
snapshot: void 0,
error
})), tap((t22) => {
const {
snapshot,
error: error_0
} = t22;
entry.snapshot = snapshot, entry.error = error_0;
}), map((value_0) => {
}), finalize(() => cache.delete(observable)), share({
resetOnRefCountZero: () => timer(0, asapScheduler)
})), entry.observable.subscribe().unsubscribe(), cache.set(observable, entry);
}
let t2;
$[2] !== observable ? (t2 = cache.get(observable), $[2] = observable, $[3] = t2) : t2 = $[3];
const instance = t2;
let t3;
$[4] !== instance.observable ? (t3 = (onStoreChange) => {
const subscription_0 = instance.observable.subscribe(onStoreChange);
return () => {
subscription_0.unsubscribe();
};
}, $[4] = instance.observable, $[5] = t3) : t3 = $[5];
let t4;
$[6] !== instance.error || $[7] !== instance.snapshot ? (t4 = () => {
if (instance.error)
throw instance.error;
return instance.snapshot;
}, $[6] = instance.error, $[7] = instance.snapshot, $[8] = t4) : t4 = $[8];
let t5;
$[9] !== t3 || $[10] !== t4 ? (t5 = {
subscribe: t3,
getSnapshot: t4
}, $[9] = t3, $[10] = t4, $[11] = t5) : t5 = $[11], t1 = t5;
const store = t1;
let t6, t7;
$[12] !== store.subscribe ? (t6 = () => {
}, [observable, getInitialValue]);
return useEffect(() => {
console.log("stor.subscribe changed", store.subscribe);
}, t7 = [store.subscribe], $[12] = store.subscribe, $[13] = t6, $[14] = t7) : (t6 = $[13], t7 = $[14]), useEffect(t6, t7);
let t8;
return $[15] !== initialValue || $[16] !== getInitialValue ? (t8 = typeof initialValue > "u" ? void 0 : () => getInitialValue(), $[15] = initialValue, $[16] = getInitialValue, $[17] = t8) : t8 = $[17], useSyncExternalStore(store.subscribe, store.getSnapshot, t8);
}, [store.subscribe]), useSyncExternalStore(
store.subscribe,
store.getSnapshot,
typeof initialValue > "u" ? void 0 : () => getInitialValue()
);
}
function useObservableEvent(handleEvent) {
const $ = c(6), [t0] = useState(_temp), [calls$, call] = t0;
let t1;
$[0] !== handleEvent ? (t1 = (observable) => handleEvent(observable), $[0] = handleEvent, $[1] = t1) : t1 = $[1];
const onEvent = useEffectEvent(t1);
let t2, t3;
return $[2] !== calls$ || $[3] !== onEvent ? (t2 = () => {
const subscription = calls$.pipe((observable_0) => onEvent(observable_0)).subscribe();
const [[calls$, call]] = useState(() => observableCallback()), onEvent = useEffectEvent((observable) => handleEvent(observable));
return useEffect(() => {
const subscription = calls$.pipe((observable) => onEvent(observable)).subscribe();
return () => subscription.unsubscribe();
}, t3 = [calls$, onEvent], $[2] = calls$, $[3] = onEvent, $[4] = t2, $[5] = t3) : (t2 = $[4], t3 = $[5]), useEffect(t2, t3), call;
}, [calls$, onEvent]), call;
}
function _temp() {
return observableCallback();
}
export {

@@ -83,0 +65,0 @@ useObservable,

{
"name": "react-rx",
"version": "4.1.2-canary.0",
"version": "4.1.2-canary.1",
"description": "React + RxJS = <3",

@@ -5,0 +5,0 @@ "keywords": [

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