@ic-reactor/react 0.2.11 → 0.3.0

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/context.js CHANGED
@@ -108,6 +108,7 @@ const ReActorProvider = (_a) => {
108
108
  return null;
109
109
  }
110
110
  }, [config, didJs]);
111
+ (0, react_1.useEffect)(() => reActorHooks === null || reActorHooks === void 0 ? void 0 : reActorHooks.unsubscribeAgent, [reActorHooks === null || reActorHooks === void 0 ? void 0 : reActorHooks.unsubscribeAgent]);
111
112
  return (react_1.default.createElement(exports.ReActorContext.Provider, { value: reActorHooks }, reActorHooks ? children : loadingComponent));
112
113
  };
113
114
  exports.ReActorProvider = ReActorProvider;
package/dist/index.d.ts CHANGED
@@ -2,10 +2,15 @@ import type { AuthClientLoginOptions } from "@dfinity/auth-client";
2
2
  import type { ReActorOptions } from "@ic-reactor/store";
3
3
  export * from "./context";
4
4
  export declare const createReActor: <A extends unknown>(options: ReActorOptions) => {
5
+ unsubscribeAgent: () => void;
5
6
  useMethodFields: () => import("@ic-reactor/store").ReActorMethodField<A>[];
6
7
  useMethodField: (functionName: keyof A & string) => import("@ic-reactor/store").ReActorMethodField<A> | undefined;
8
+ useAgentStore: () => {
9
+ initializeAgent: (agentOptions?: import("@dfinity/agent").HttpAgentOptions | undefined, isLocal?: boolean | undefined) => Promise<void>;
10
+ agent: import("@ic-reactor/store").HttpAgent | undefined;
11
+ canisterId: import("@ic-reactor/store").CanisterId;
12
+ };
7
13
  useActorStore: () => {
8
- initialize: (agentOptions?: import("@dfinity/agent").HttpAgentOptions | undefined, isLocal?: boolean | undefined) => void;
9
14
  actor: A | null;
10
15
  initialized: boolean;
11
16
  initializing: boolean;
package/dist/index.js CHANGED
@@ -33,10 +33,14 @@ const createReActor = (options) => {
33
33
  const isLocal = typeof process !== "undefined" &&
34
34
  (process.env.NODE_ENV === "development" ||
35
35
  process.env.DFX_NETWORK === "local");
36
- const { callMethod, initialize, authenticate, authStore, actorStore } = (0, store_1.createReActorStore)(Object.assign({ isLocal }, options));
36
+ const { unsubscribeAgent, initializeAgent, authenticate, callMethod, authStore, agentStore, actorStore, } = (0, store_1.createReActorStore)(Object.assign({ isLocal }, options));
37
+ const useAgentStore = () => {
38
+ const agentState = (0, zustand_1.useStore)(agentStore, (state) => state);
39
+ return Object.assign(Object.assign({}, agentState), { initializeAgent });
40
+ };
37
41
  const useActorStore = () => {
38
42
  const actorState = (0, zustand_1.useStore)(actorStore, (state) => state);
39
- return Object.assign(Object.assign({}, actorState), { initialize });
43
+ return Object.assign({}, actorState);
40
44
  };
41
45
  const useAuthStore = () => {
42
46
  const authState = (0, zustand_1.useStore)(authStore, (state) => state);
@@ -90,8 +94,10 @@ const createReActor = (options) => {
90
94
  };
91
95
  const { useQueryCall, useMethodField, useMethodFields, useUpdateCall } = (0, hooks_1.getCallHooks)(callMethod, actorStore);
92
96
  return {
97
+ unsubscribeAgent,
93
98
  useMethodFields,
94
99
  useMethodField,
100
+ useAgentStore,
95
101
  useActorStore,
96
102
  useAuthStore,
97
103
  useQueryCall,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ic-reactor/react",
3
- "version": "0.2.11",
3
+ "version": "0.3.0",
4
4
  "description": "A React library for interacting with Dfinity actors",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  "node": ">=10"
36
36
  },
37
37
  "dependencies": {
38
- "@ic-reactor/store": "^0.2.10",
38
+ "@ic-reactor/store": "^0.3.0",
39
39
  "zustand-utils": "^1.3"
40
40
  },
41
41
  "peerDependencies": {
@@ -48,5 +48,5 @@
48
48
  "react": ">=16.8",
49
49
  "zustand": "4.4"
50
50
  },
51
- "gitHead": "380eb64826d23ae062dd634ff28ee9f8409d4ef0"
51
+ "gitHead": "00b0d7f282c144151f27d344c47d92b9b446b14a"
52
52
  }