@8ms/helpers 2.4.12 → 2.4.14
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/dist/drizzle/server/DrizzleNamespace.d.cts +0 -1
- package/dist/drizzle/server/DrizzleNamespace.d.mts +1 -0
- package/dist/nextJs/client/useAsyncEffect.cjs +5 -2
- package/dist/nextJs/client/useAsyncEffect.d.cts +2 -1
- package/dist/nextJs/client/useAsyncEffect.d.mts +2 -1
- package/dist/nextJs/client/useAsyncEffect.mjs +5 -2
- package/package.json +1 -1
|
@@ -2,7 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
//#region src/nextJs/client/useAsyncEffect.ts
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Based on https://github.com/rauldeheer/use-async-effect/tree/master
|
|
7
|
+
*/
|
|
8
|
+
function useAsyncEffect(effect, destroy, inputs) {
|
|
6
9
|
const hasDestroy = typeof destroy === "function";
|
|
7
10
|
(0, react.useEffect)(function() {
|
|
8
11
|
let result;
|
|
@@ -18,6 +21,6 @@ const useAsyncEffect = (effect, destroy, inputs) => {
|
|
|
18
21
|
if (hasDestroy) destroy(result);
|
|
19
22
|
};
|
|
20
23
|
}, hasDestroy ? inputs : destroy);
|
|
21
|
-
}
|
|
24
|
+
}
|
|
22
25
|
//#endregion
|
|
23
26
|
exports.useAsyncEffect = useAsyncEffect;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
//#region src/nextJs/client/useAsyncEffect.d.ts
|
|
2
|
-
declare
|
|
2
|
+
declare function useAsyncEffect(effect: (isMounted: () => boolean) => unknown | Promise<unknown>, inputs?: any[]): void;
|
|
3
|
+
declare function useAsyncEffect<V>(effect: (isMounted: () => boolean) => V | Promise<V>, destroy?: (result?: V) => void, inputs?: any[]): void;
|
|
3
4
|
//#endregion
|
|
4
5
|
export { useAsyncEffect };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
//#region src/nextJs/client/useAsyncEffect.d.ts
|
|
2
|
-
declare
|
|
2
|
+
declare function useAsyncEffect(effect: (isMounted: () => boolean) => unknown | Promise<unknown>, inputs?: any[]): void;
|
|
3
|
+
declare function useAsyncEffect<V>(effect: (isMounted: () => boolean) => V | Promise<V>, destroy?: (result?: V) => void, inputs?: any[]): void;
|
|
3
4
|
//#endregion
|
|
4
5
|
export { useAsyncEffect };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
//#region src/nextJs/client/useAsyncEffect.ts
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Based on https://github.com/rauldeheer/use-async-effect/tree/master
|
|
5
|
+
*/
|
|
6
|
+
function useAsyncEffect(effect, destroy, inputs) {
|
|
4
7
|
const hasDestroy = typeof destroy === "function";
|
|
5
8
|
useEffect(function() {
|
|
6
9
|
let result;
|
|
@@ -16,6 +19,6 @@ const useAsyncEffect = (effect, destroy, inputs) => {
|
|
|
16
19
|
if (hasDestroy) destroy(result);
|
|
17
20
|
};
|
|
18
21
|
}, hasDestroy ? inputs : destroy);
|
|
19
|
-
}
|
|
22
|
+
}
|
|
20
23
|
//#endregion
|
|
21
24
|
export { useAsyncEffect };
|