@reonomy/reactive-hooks
Advanced tools
Comparing version 1.1.4 to 1.2.0
@@ -0,1 +1,4 @@ | ||
export interface Disposable { | ||
(): (() => void) | void; | ||
} | ||
/** | ||
@@ -5,5 +8,5 @@ * `useMountEffect` | ||
* Handles component onMount() in the render function. | ||
* @param {VoidFunction} onMountCallback - this function will be called only once when the component is mounted. | ||
* @param {Disposable} onMountCallback - this function will be called only once when the component is mounted. | ||
*/ | ||
export declare function useMountEffect(onMountCallback: VoidFunction): void; | ||
export declare function useMountEffect(onMountCallback: Disposable): void; | ||
export default useMountEffect; |
@@ -8,12 +8,6 @@ "use strict"; | ||
* Handles component onMount() in the render function. | ||
* @param {VoidFunction} onMountCallback - this function will be called only once when the component is mounted. | ||
* @param {Disposable} onMountCallback - this function will be called only once when the component is mounted. | ||
*/ | ||
function useMountEffect(onMountCallback) { | ||
var _a = react_1.useState(false), wasMounted = _a[0], setMounted = _a[1]; | ||
react_1.useEffect(function () { | ||
if (!wasMounted) { | ||
setMounted(true); | ||
onMountCallback(); | ||
} | ||
}); | ||
react_1.useEffect(function () { return onMountCallback(); }, []); | ||
} | ||
@@ -20,0 +14,0 @@ exports.useMountEffect = useMountEffect; |
@@ -20,3 +20,2 @@ "use strict"; | ||
function useRxAjax(api$, next) { | ||
var a = ''; | ||
var req$ = react_1.useState(function () { return new Subject_1.Subject(); })[0]; | ||
@@ -23,0 +22,0 @@ var res$ = react_1.useMemo(function () { return req$.pipe(http_1.http(api$)); }, [req$]); |
{ | ||
"name": "@reonomy/reactive-hooks", | ||
"version": "1.1.4", | ||
"version": "1.2.0", | ||
"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
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
29681
470