@react-pakistan/util-functions 1.24.1 → 1.24.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.
@@ -5,17 +5,21 @@ export interface CallbackParams {
5
5
  }
6
6
  interface Params {
7
7
  byIdCallback: (d: CallbackParams) => void;
8
+ byIdDeps?: Array<any> | Array<string>;
8
9
  byIdParams: object;
9
10
  deleteCallback?: (d: CallbackParams) => void;
11
+ deleteDeps?: Array<any> | Array<string>;
10
12
  deleteParams?: object;
11
13
  listCallback: (d: CallbackParams) => void;
14
+ listDeps?: Array<any> | Array<string>;
12
15
  listParams: object;
13
16
  listUrl: string;
17
+ searchQuery: string;
14
18
  unitByIdUrl: string;
15
19
  unitUrl: string;
16
20
  updateCallback: (d: CallbackParams) => void;
21
+ updateDeps?: Array<any> | Array<string>;
17
22
  updateParams: object;
18
- searchQuery: string;
19
23
  }
20
24
  interface Return {
21
25
  byIdError: Error;
@@ -31,5 +35,5 @@ interface Return {
31
35
  updateFetchNow: (url?: string, config?: FetchConfig) => void;
32
36
  updateLoading: boolean;
33
37
  }
34
- export declare const useModuleEntity: ({ byIdCallback, byIdParams, deleteCallback, deleteParams, listCallback, listParams, listUrl, unitByIdUrl, unitUrl, updateCallback, updateParams, searchQuery, }: Params) => Return;
38
+ export declare const useModuleEntity: ({ byIdCallback, byIdDeps, byIdParams, deleteCallback, deleteDeps, deleteParams, listCallback, listDeps, listParams, listUrl, searchQuery, unitByIdUrl, unitUrl, updateCallback, updateDeps, updateParams, }: Params) => Return;
35
39
  export {};
@@ -1,37 +1,46 @@
1
1
  "use strict";
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
4
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
5
+ if (ar || !(i in from)) {
6
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
7
+ ar[i] = from[i];
8
+ }
9
+ }
10
+ return to.concat(ar || Array.prototype.slice.call(from));
11
+ };
3
12
  Object.defineProperty(exports, "__esModule", { value: true });
4
13
  exports.useModuleEntity = void 0;
5
14
  var constants_1 = require("../constants");
6
15
  var use_fetch_1 = require("./use-fetch");
7
16
  var use_debounce_1 = require("./use-debounce");
8
17
  var useModuleEntity = function (_a) {
9
- var byIdCallback = _a.byIdCallback, byIdParams = _a.byIdParams, deleteCallback = _a.deleteCallback, deleteParams = _a.deleteParams, listCallback = _a.listCallback, listParams = _a.listParams, listUrl = _a.listUrl, unitByIdUrl = _a.unitByIdUrl, unitUrl = _a.unitUrl, updateCallback = _a.updateCallback, updateParams = _a.updateParams, searchQuery = _a.searchQuery;
18
+ var byIdCallback = _a.byIdCallback, _b = _a.byIdDeps, byIdDeps = _b === void 0 ? [] : _b, byIdParams = _a.byIdParams, deleteCallback = _a.deleteCallback, _c = _a.deleteDeps, deleteDeps = _c === void 0 ? [] : _c, deleteParams = _a.deleteParams, listCallback = _a.listCallback, _d = _a.listDeps, listDeps = _d === void 0 ? [] : _d, listParams = _a.listParams, listUrl = _a.listUrl, searchQuery = _a.searchQuery, unitByIdUrl = _a.unitByIdUrl, unitUrl = _a.unitUrl, updateCallback = _a.updateCallback, _e = _a.updateDeps, updateDeps = _e === void 0 ? [] : _e, updateParams = _a.updateParams;
10
19
  var debouncedQuery = (0, use_debounce_1.useDebounce)(searchQuery, 800);
11
20
  // list
12
- var _b = (0, use_fetch_1.useFetch)(listUrl, {
21
+ var _f = (0, use_fetch_1.useFetch)(listUrl, {
13
22
  method: constants_1.API_METHODS.POST,
14
23
  body: JSON.stringify(listParams),
15
24
  callback: listCallback,
16
- }, [debouncedQuery]), listError = _b.error, listFetchNow = _b.fetchNow, listLoading = _b.loading;
25
+ }, __spreadArray([debouncedQuery], listDeps, true)), listError = _f.error, listFetchNow = _f.fetchNow, listLoading = _f.loading;
17
26
  // create / edit
18
- var _c = (0, use_fetch_1.useFetch)(unitUrl, {
27
+ var _g = (0, use_fetch_1.useFetch)(unitUrl, {
19
28
  method: constants_1.API_METHODS.POST,
20
29
  body: JSON.stringify(updateParams),
21
30
  callback: updateCallback,
22
- }), updateError = _c.error, updateLoading = _c.loading, updateFetchNow = _c.fetchNow;
31
+ }, __spreadArray([], updateDeps, true)), updateError = _g.error, updateLoading = _g.loading, updateFetchNow = _g.fetchNow;
23
32
  // by id
24
- var _d = (0, use_fetch_1.useFetch)(unitByIdUrl, {
33
+ var _h = (0, use_fetch_1.useFetch)(unitByIdUrl, {
25
34
  method: constants_1.API_METHODS.POST,
26
35
  body: JSON.stringify(byIdParams),
27
36
  callback: byIdCallback,
28
- }), byIdError = _d.error, byIdLoading = _d.loading, byIdFetchNow = _d.fetchNow;
37
+ }, __spreadArray([], byIdDeps, true)), byIdError = _h.error, byIdLoading = _h.loading, byIdFetchNow = _h.fetchNow;
29
38
  // delete
30
- var _e = (0, use_fetch_1.useFetch)(unitUrl, {
39
+ var _j = (0, use_fetch_1.useFetch)(unitUrl, {
31
40
  method: constants_1.API_METHODS.DELETE,
32
41
  body: JSON.stringify(deleteParams),
33
42
  callback: deleteCallback,
34
- }), deleteError = _e.error, deleteLoading = _e.loading, deleteFetchNow = _e.fetchNow;
43
+ }, __spreadArray([], deleteDeps, true)), deleteError = _j.error, deleteLoading = _j.loading, deleteFetchNow = _j.fetchNow;
35
44
  return {
36
45
  byIdError: byIdError,
37
46
  byIdFetchNow: byIdFetchNow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.24.1",
3
+ "version": "1.24.2",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {