@faasjs/react 0.0.2-beta.285 → 0.0.2-beta.286

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 CHANGED
@@ -172,6 +172,12 @@
172
172
  setPromise,
173
173
  setError,
174
174
  };
175
+ },
176
+ FaasData({ action, params, fallback, element }) {
177
+ const request = this.useFaas(action, params);
178
+ if (request.loading && fallback !== false)
179
+ return fallback || null;
180
+ return element(request);
175
181
  }
176
182
  };
177
183
  }
@@ -1,7 +1,7 @@
1
+ /// <reference types="react" />
1
2
  import { Options, Params, Response, ResponseError } from '../../browser/src';
2
3
  export type { FaasBrowserClient, Options, Params, Response, ResponseHeaders, ResponseError } from '../../browser/src';
3
- export declare type faas = <T = any>(action: string, params: Params) => Promise<Response<T>>;
4
- export declare type useFaas = <T = any>(action: string, params: Params) => {
4
+ declare type FaasDataInjection<T = any> = {
5
5
  loading: boolean;
6
6
  data: T;
7
7
  error: any;
@@ -12,11 +12,18 @@ export declare type useFaas = <T = any>(action: string, params: Params) => {
12
12
  setPromise(promise: Promise<Response<T>>): void;
13
13
  setError(error: any): void;
14
14
  };
15
+ declare type FaasDataProps<T = any> = {
16
+ element(args: FaasDataInjection<T>): JSX.Element;
17
+ fallback?: JSX.Element | false;
18
+ action: string;
19
+ params?: Params;
20
+ };
15
21
  export declare function FaasReactClient({ domain, options, onError }: {
16
22
  domain: string;
17
23
  options?: Options;
18
24
  onError?: (action: string, params: Params) => (res: ResponseError) => Promise<any>;
19
25
  }): {
20
- faas: faas;
21
- useFaas: useFaas;
26
+ faas<T = any>(action: string, params: Params): Promise<Response<T>>;
27
+ useFaas<T_1 = any>(action: string, defaultParams: Params): FaasDataInjection<T_1>;
28
+ FaasData<T_2 = any>({ action, params, fallback, element }: FaasDataProps<T_2>): JSX.Element;
22
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/react",
3
- "version": "0.0.2-beta.285",
3
+ "version": "0.0.2-beta.286",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/react/src/index.d.ts",
@@ -27,5 +27,5 @@
27
27
  "rollup-plugin-typescript2": "*",
28
28
  "typescript": "*"
29
29
  },
30
- "gitHead": "1d4ddf33b9a267f7a2dc48ccbb888613b3727de3"
30
+ "gitHead": "d75e396ec29cba1c49c87c5bbee0a3685c00747d"
31
31
  }