Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@reonomy/reactive-hooks

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reonomy/reactive-hooks - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

24

lib/use-rx-ajax.js

@@ -6,3 +6,8 @@ "use strict";

var http_1 = require("./http");
var use_rx_1 = require("./use-rx");
var use_rx_effect_1 = require("./use-rx-effect");
function useReqRes(api$) {
var req$ = new Subject_1.Subject();
var res$ = req$.pipe(http_1.http(api$));
return [res$, req$.next.bind(req$)];
}
/**

@@ -21,16 +26,13 @@ * `useRxAjax`

function useRxAjax(api$, next) {
var req$ = react_1.useState(function () { return new Subject_1.Subject(); })[0];
var res$ = react_1.useMemo(function () { return req$.pipe(http_1.http(api$)); }, [req$]);
var _a = react_1.useState(), res = _a[0], setRes = _a[1];
use_rx_1.useRx(res$, {
next: function (nextRes) {
setRes(nextRes);
if (next) {
next(nextRes);
}
var _a = react_1.useMemo(function () { return useReqRes(api$); }, [api$]), res$ = _a[0], submitReq = _a[1];
var _b = react_1.useState(), res = _b[0], setRes = _b[1];
use_rx_effect_1.useRxEffect(res$, function (nextRes) {
setRes(nextRes);
if (next) {
next(nextRes);
}
});
return [res, req$.next.bind(req$)];
return [res, submitReq];
}
exports.useRxAjax = useRxAjax;
//# sourceMappingURL=use-rx-ajax.js.map

@@ -31,2 +31,19 @@ "use strict";

exports.initialObservableValue = initialObservableValue;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function createRxConfig(subject$) {
var initVal = initialObservableValue(subject$);
var hadInitVal = initVal !== exports.UNSET_VALUE;
var isSubject = hasNext(subject$);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var nextValue = isSubject ? subject$.next.bind(subject$) : undefined;
var observer = new mutable_observer_1.MutableObserver();
return {
isSubject: isSubject,
initVal: initVal,
hadInitVal: hadInitVal,
isNext: !hadInitVal,
nextValue: nextValue,
observer: observer
};
}
/**

@@ -48,16 +65,5 @@ * `useRxState`

function useRxState(subject$) {
var initObj = react_1.useMemo(function () {
var initVal = initialObservableValue(subject$);
var hadInitVal = initVal !== exports.UNSET_VALUE;
return {
isSubject: hasNext(subject$),
initVal: initVal,
hadInitVal: hadInitVal,
isNext: !hadInitVal
};
}, [subject$]);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var observer = react_1.useMemo(function () { return new mutable_observer_1.MutableObserver(); }, [subject$]);
var initObj = react_1.useMemo(function () { return createRxConfig(subject$); }, [subject$]);
var _a = react_1.useState(function () { return (initObj.hadInitVal ? initObj.initVal : undefined); }), value = _a[0], setValue = _a[1];
observer.setNext(function (nextValue) {
initObj.observer.setNext(function (nextValue) {
if (initObj.isNext) {

@@ -71,7 +77,5 @@ setValue(nextValue);

});
use_rx_1.useRx(subject$, observer);
use_rx_1.useRx(subject$, initObj.observer);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var nextValue = initObj.isSubject ? subject$.next.bind(subject$) : undefined;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return [value, nextValue];
return [value, initObj.nextValue];
}

@@ -103,5 +107,6 @@ exports.useRxState = useRxState;

function useRxStateAction(subject$) {
return subject$.next.bind(subject$);
var next = react_1.useMemo(function () { return subject$.next.bind(subject$); }, [subject$]);
return next;
}
exports.useRxStateAction = useRxStateAction;
//# sourceMappingURL=use-rx-state.js.map
{
"name": "@reonomy/reactive-hooks",
"version": "1.2.0",
"version": "1.2.1",
"description": "RxJS React Hooks Library",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc