@8ms/helpers 2.4.13 → 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.
@@ -1,6 +1,5 @@
1
1
  import { BaseNamespace } from "../../_class/BaseNamespace.cjs";
2
2
  import { DrizzleConfig } from "./drizzle.cjs";
3
-
4
3
  //#region src/drizzle/server/DrizzleNamespace.d.ts
5
4
  declare class DrizzleNamespace<TClient = any> extends BaseNamespace {
6
5
  client: TClient;
@@ -1,5 +1,6 @@
1
1
  import { BaseNamespace } from "../../_class/BaseNamespace.mjs";
2
2
  import { DrizzleConfig } from "./drizzle.mjs";
3
+
3
4
  //#region src/drizzle/server/DrizzleNamespace.d.ts
4
5
  declare class DrizzleNamespace<TClient = any> extends BaseNamespace {
5
6
  client: TClient;
@@ -2,21 +2,25 @@ 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
- const useAsyncEffect = (effect, destroyOrInputs, inputs) => {
6
- const hasDestroy = "function" === typeof destroyOrInputs;
7
- const destroy = hasDestroy ? destroyOrInputs : void 0;
8
- (0, react.useEffect)(() => {
5
+ /**
6
+ * Based on https://github.com/rauldeheer/use-async-effect/tree/master
7
+ */
8
+ function useAsyncEffect(effect, destroy, inputs) {
9
+ const hasDestroy = typeof destroy === "function";
10
+ (0, react.useEffect)(function() {
9
11
  let result;
10
12
  let mounted = true;
11
- const maybePromise = effect(() => mounted);
12
- Promise.resolve(maybePromise).then((value) => {
13
+ let maybePromise = effect(function() {
14
+ return mounted;
15
+ });
16
+ Promise.resolve(maybePromise).then(function(value) {
13
17
  result = value;
14
18
  });
15
- return () => {
19
+ return function() {
16
20
  mounted = false;
17
- if (hasDestroy && destroy) destroy(result);
21
+ if (hasDestroy) destroy(result);
18
22
  };
19
- }, hasDestroy ? inputs : destroyOrInputs);
20
- };
23
+ }, hasDestroy ? inputs : destroy);
24
+ }
21
25
  //#endregion
22
26
  exports.useAsyncEffect = useAsyncEffect;
@@ -1,8 +1,5 @@
1
1
  //#region src/nextJs/client/useAsyncEffect.d.ts
2
- type UseAsyncEffect = {
3
- (effect: (isMounted: () => boolean) => unknown | Promise<unknown>, inputs?: any[]): void;
4
- <T>(effect: (isMounted: () => boolean) => T | Promise<T>, destroy?: (result?: T) => void, inputs?: any[]): void;
5
- };
6
- declare const useAsyncEffect: UseAsyncEffect;
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;
7
4
  //#endregion
8
5
  export { useAsyncEffect };
@@ -1,8 +1,5 @@
1
1
  //#region src/nextJs/client/useAsyncEffect.d.ts
2
- type UseAsyncEffect = {
3
- (effect: (isMounted: () => boolean) => unknown | Promise<unknown>, inputs?: any[]): void;
4
- <T>(effect: (isMounted: () => boolean) => T | Promise<T>, destroy?: (result?: T) => void, inputs?: any[]): void;
5
- };
6
- declare const useAsyncEffect: UseAsyncEffect;
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;
7
4
  //#endregion
8
5
  export { useAsyncEffect };
@@ -1,20 +1,24 @@
1
1
  import { useEffect } from "react";
2
2
  //#region src/nextJs/client/useAsyncEffect.ts
3
- const useAsyncEffect = (effect, destroyOrInputs, inputs) => {
4
- const hasDestroy = "function" === typeof destroyOrInputs;
5
- const destroy = hasDestroy ? destroyOrInputs : void 0;
6
- useEffect(() => {
3
+ /**
4
+ * Based on https://github.com/rauldeheer/use-async-effect/tree/master
5
+ */
6
+ function useAsyncEffect(effect, destroy, inputs) {
7
+ const hasDestroy = typeof destroy === "function";
8
+ useEffect(function() {
7
9
  let result;
8
10
  let mounted = true;
9
- const maybePromise = effect(() => mounted);
10
- Promise.resolve(maybePromise).then((value) => {
11
+ let maybePromise = effect(function() {
12
+ return mounted;
13
+ });
14
+ Promise.resolve(maybePromise).then(function(value) {
11
15
  result = value;
12
16
  });
13
- return () => {
17
+ return function() {
14
18
  mounted = false;
15
- if (hasDestroy && destroy) destroy(result);
19
+ if (hasDestroy) destroy(result);
16
20
  };
17
- }, hasDestroy ? inputs : destroyOrInputs);
18
- };
21
+ }, hasDestroy ? inputs : destroy);
22
+ }
19
23
  //#endregion
20
24
  export { useAsyncEffect };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.4.13",
4
+ "version": "2.4.14",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"