@faasjs/react 0.0.2-beta.302 → 0.0.2-beta.310
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/lib/index.js +1 -2
- package/lib/react/src/index.d.ts +17 -16
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
function FaasReactClient({ domain, options, onError }) {
|
|
8
8
|
const client = new browser.FaasBrowserClient(domain, options);
|
|
9
|
-
// async function faas<Path extends keyof FaasActions> (action: Path, params: FaasActions[Path]['request']): Promise<Response<FaasActions[Path]['response']>>
|
|
10
9
|
async function faas(action, params) {
|
|
11
10
|
if (onError)
|
|
12
11
|
return client.action(action, params)
|
|
@@ -80,7 +79,7 @@
|
|
|
80
79
|
if (!loaded && !request.loading)
|
|
81
80
|
setLoaded(true);
|
|
82
81
|
}, [request.loading]);
|
|
83
|
-
react.useEffect(()
|
|
82
|
+
react.useEffect(function () {
|
|
84
83
|
if (onDataChange)
|
|
85
84
|
onDataChange(request);
|
|
86
85
|
}, [JSON.stringify(request.data)]);
|
package/lib/react/src/index.d.ts
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Options,
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { Options, Response, ResponseError } from '@faasjs/browser';
|
|
3
|
+
import { FaasAction, FaasData, FaasParams } from '@faasjs/types';
|
|
4
|
+
export type { FaasBrowserClient, Options, Response, ResponseHeaders, ResponseError } from '@faasjs/browser';
|
|
5
|
+
declare type FaasDataInjection<Data = any> = {
|
|
5
6
|
loading: boolean;
|
|
6
|
-
data:
|
|
7
|
+
data: Data;
|
|
7
8
|
error: any;
|
|
8
|
-
promise: Promise<Response<
|
|
9
|
-
reload(params?:
|
|
10
|
-
setData: React.Dispatch<React.SetStateAction<
|
|
9
|
+
promise: Promise<Response<Data>>;
|
|
10
|
+
reload(params?: Record<string, any>): Promise<Response<Data>>;
|
|
11
|
+
setData: React.Dispatch<React.SetStateAction<Data>>;
|
|
11
12
|
setLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
12
|
-
setPromise: React.Dispatch<React.SetStateAction<Promise<Response<
|
|
13
|
+
setPromise: React.Dispatch<React.SetStateAction<Promise<Response<Data>>>>;
|
|
13
14
|
setError: React.Dispatch<React.SetStateAction<any>>;
|
|
14
15
|
};
|
|
15
|
-
declare type FaasDataProps<
|
|
16
|
-
element(args: FaasDataInjection<
|
|
16
|
+
declare type FaasDataProps<PathOrData extends FaasAction> = {
|
|
17
|
+
element(args: FaasDataInjection<FaasData<PathOrData>>): JSX.Element;
|
|
17
18
|
fallback?: JSX.Element | false;
|
|
18
19
|
action: string;
|
|
19
|
-
params?:
|
|
20
|
-
onDataChange?(args: FaasDataInjection<
|
|
20
|
+
params?: FaasParams<PathOrData>;
|
|
21
|
+
onDataChange?(args: FaasDataInjection<FaasData<PathOrData>>): void;
|
|
21
22
|
};
|
|
22
23
|
export declare function FaasReactClient({ domain, options, onError }: {
|
|
23
24
|
domain: string;
|
|
24
25
|
options?: Options;
|
|
25
|
-
onError?: (action: string, params:
|
|
26
|
+
onError?: (action: string, params: Record<string, any>) => (res: ResponseError) => Promise<void>;
|
|
26
27
|
}): {
|
|
27
|
-
faas: <
|
|
28
|
-
useFaas: <
|
|
29
|
-
FaasData<
|
|
28
|
+
faas: <PathOrData extends FaasAction>(action: string | PathOrData, params: FaasParams<PathOrData>) => Promise<Response<FaasData<PathOrData>>>;
|
|
29
|
+
useFaas: <PathOrData extends FaasAction>(action: string | PathOrData, defaultParams: FaasParams<PathOrData>) => FaasDataInjection<FaasData<PathOrData>>;
|
|
30
|
+
FaasData<PathOrData extends FaasAction>(props: FaasDataProps<PathOrData>): JSX.Element;
|
|
30
31
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/react",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.310",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/react/src/index.d.ts",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"engines": {
|
|
35
35
|
"npm": ">=8.0.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "0bfca56ec223e3b4b8fd91e51058263f010d4ea6"
|
|
38
38
|
}
|