applesauce-react 0.0.0-next-20250313225050 → 0.0.0-next-20250314133024

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,5 +1,6 @@
1
1
  import { ActionConstructor } from "applesauce-actions";
2
- export declare function useAction<Args extends Array<any>, T extends unknown = unknown>(Action: ActionConstructor<Args, T>, args: Args | undefined): {
2
+ export declare function useAction<Args extends Array<any>>(Action: ActionConstructor<Args>, args: Args | undefined): {
3
3
  loading: boolean;
4
4
  run: () => Promise<void>;
5
+ exec: () => import("rxjs").Observable<import("nostr-tools").Event> | undefined;
5
6
  };
@@ -1,4 +1,5 @@
1
1
  import { useCallback, useRef, useState } from "react";
2
+ import { finalize } from "rxjs";
2
3
  import { useActionHub } from "./use-action-hub.js";
3
4
  export function useAction(Action, args) {
4
5
  const [loading, setLoading] = useState(false);
@@ -18,5 +19,19 @@ export function useAction(Action, args) {
18
19
  throw error;
19
20
  }
20
21
  }, [Action]);
21
- return { loading, run };
22
+ const exec = useCallback(() => {
23
+ if (args === undefined)
24
+ return;
25
+ setLoading(true);
26
+ try {
27
+ return hub.exec(Action, ...args).pipe(finalize(() => {
28
+ setLoading(false);
29
+ }));
30
+ }
31
+ catch (error) {
32
+ setLoading(false);
33
+ throw error;
34
+ }
35
+ }, [Action]);
36
+ return { loading, run, exec };
22
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-react",
3
- "version": "0.0.0-next-20250313225050",
3
+ "version": "0.0.0-next-20250314133024",
4
4
  "description": "React hooks for applesauce",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -49,11 +49,11 @@
49
49
  }
50
50
  },
51
51
  "dependencies": {
52
- "applesauce-accounts": "0.0.0-next-20250313225050",
53
- "applesauce-actions": "0.0.0-next-20250313225050",
54
- "applesauce-content": "0.0.0-next-20250313225050",
55
- "applesauce-core": "0.0.0-next-20250313225050",
56
- "applesauce-factory": "0.0.0-next-20250313225050",
52
+ "applesauce-accounts": "0.0.0-next-20250314133024",
53
+ "applesauce-actions": "0.0.0-next-20250314133024",
54
+ "applesauce-content": "0.0.0-next-20250314133024",
55
+ "applesauce-core": "0.0.0-next-20250314133024",
56
+ "applesauce-factory": "0.0.0-next-20250314133024",
57
57
  "nostr-tools": "^2.10.4",
58
58
  "observable-hooks": "^4.2.4",
59
59
  "react": "^18.3.1",