@ic-reactor/core 0.2.0 → 0.2.2
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/index.js +3 -3
- package/dist/types.d.ts +2 -2
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ const createReActor = (options) => {
|
|
|
35
35
|
console.error(`Method ${String(method)} not found`);
|
|
36
36
|
return state;
|
|
37
37
|
}
|
|
38
|
-
const currentMethodState = state.methodState[method]
|
|
38
|
+
const currentMethodState = state.methodState[method][hash] || {
|
|
39
39
|
loading: false,
|
|
40
40
|
data: undefined,
|
|
41
41
|
error: undefined,
|
|
@@ -48,7 +48,7 @@ const createReActor = (options) => {
|
|
|
48
48
|
try {
|
|
49
49
|
const requestHash = updateMethodState(functionName, args);
|
|
50
50
|
const getState = (key) => {
|
|
51
|
-
const state = actorStore.getState().methodState[functionName]
|
|
51
|
+
const state = actorStore.getState().methodState[functionName][requestHash];
|
|
52
52
|
switch (key) {
|
|
53
53
|
case "data":
|
|
54
54
|
return state.data;
|
|
@@ -63,7 +63,7 @@ const createReActor = (options) => {
|
|
|
63
63
|
const subscribe = (callback) => {
|
|
64
64
|
const unsubscribe = actorStore.subscribe((state) => {
|
|
65
65
|
const methodState = state.methodState[functionName];
|
|
66
|
-
const methodStateHash = methodState
|
|
66
|
+
const methodStateHash = methodState[requestHash];
|
|
67
67
|
if (methodStateHash) {
|
|
68
68
|
callback(methodStateHash);
|
|
69
69
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ export type ReActorGetStateFunction<A, M extends keyof A> = {
|
|
|
4
4
|
(key: "data"): ExtractReActorMethodReturnType<A[M]> | undefined;
|
|
5
5
|
(key: "loading"): boolean;
|
|
6
6
|
(key: "error"): Error | undefined;
|
|
7
|
-
(): ReActorMethodState<A, M>[
|
|
7
|
+
(): ReActorMethodState<A, M>[string];
|
|
8
8
|
};
|
|
9
|
-
export type ReActorSubscribeFunction<A, M extends keyof A> = (callback: (state: ReActorMethodState<A, M>[
|
|
9
|
+
export type ReActorSubscribeFunction<A, M extends keyof A> = (callback: (state: ReActorMethodState<A, M>[string]) => void) => () => void;
|
|
10
10
|
export type ReActorCallFunction<A, M extends keyof A> = (replaceArgs?: ExtractReActorMethodArgs<A[M]>) => Promise<ExtractReActorMethodReturnType<A[M]> | undefined>;
|
|
11
11
|
export type ReActorQueryReturn<A, M extends keyof A> = {
|
|
12
12
|
intervalId: NodeJS.Timeout | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ic-reactor/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "A React library for interacting with Dfinity actors",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"test": "npx jest",
|
|
30
30
|
"start": "tsc watch",
|
|
31
|
-
"build": "npx tsc",
|
|
32
|
-
"clean": "rimraf dist"
|
|
31
|
+
"build": "npx rimraf dist && npx tsc",
|
|
32
|
+
"clean": "npx rimraf dist"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=10"
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"@dfinity/candid": "0.20",
|
|
41
41
|
"@dfinity/identity": "^0.20",
|
|
42
42
|
"@dfinity/principal": "^0.20",
|
|
43
|
-
"@ic-reactor/store": "^0.2.
|
|
43
|
+
"@ic-reactor/store": "^0.2.2",
|
|
44
44
|
"zustand": "4.4"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@peculiar/webcrypto": "1.4"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "97c96f8577f6cf748fca237932c3903638002d1e"
|
|
50
50
|
}
|