enlace 0.0.1-beta.12 → 0.0.1-beta.13

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.
@@ -52,6 +52,13 @@ function hookReducer(state, action) {
52
52
  fetching: true,
53
53
  error: void 0
54
54
  };
55
+ case "MUTATION_START":
56
+ return {
57
+ ...state,
58
+ loading: true,
59
+ fetching: true,
60
+ error: void 0
61
+ };
55
62
  case "FETCH_SUCCESS":
56
63
  return {
57
64
  loading: false,
@@ -239,23 +246,19 @@ function useQueryMode(api, trackedCall, options) {
239
246
  }
240
247
  const method = current[trackedCall.method];
241
248
  const fetchPromise = method(trackedCall.options).then((res) => {
242
- if (mountedRef.current) {
243
- setCache(queryKey, {
244
- data: res.error ? void 0 : res.data,
245
- error: res.error,
246
- timestamp: Date.now(),
247
- tags: queryTags
248
- });
249
- }
249
+ setCache(queryKey, {
250
+ data: res.error ? void 0 : res.data,
251
+ error: res.error,
252
+ timestamp: Date.now(),
253
+ tags: queryTags
254
+ });
250
255
  }).catch((err) => {
251
- if (mountedRef.current) {
252
- setCache(queryKey, {
253
- data: void 0,
254
- error: err,
255
- timestamp: Date.now(),
256
- tags: queryTags
257
- });
258
- }
256
+ setCache(queryKey, {
257
+ data: void 0,
258
+ error: err,
259
+ timestamp: Date.now(),
260
+ tags: queryTags
261
+ });
259
262
  });
260
263
  setCache(queryKey, {
261
264
  promise: fetchPromise,
@@ -359,7 +362,7 @@ function useSelectorMode(config) {
359
362
  autoRevalidateRef.current = autoRevalidateTags;
360
363
  if (!triggerRef.current) {
361
364
  triggerRef.current = (async (...args) => {
362
- dispatch({ type: "FETCH_START" });
365
+ dispatch({ type: "MUTATION_START" });
363
366
  const options = args[0];
364
367
  const resolvedPath = resolvePath2(pathRef.current, options?.params);
365
368
  let res;
@@ -27,6 +27,13 @@ function hookReducer(state, action) {
27
27
  fetching: true,
28
28
  error: void 0
29
29
  };
30
+ case "MUTATION_START":
31
+ return {
32
+ ...state,
33
+ loading: true,
34
+ fetching: true,
35
+ error: void 0
36
+ };
30
37
  case "FETCH_SUCCESS":
31
38
  return {
32
39
  loading: false,
@@ -214,23 +221,19 @@ function useQueryMode(api, trackedCall, options) {
214
221
  }
215
222
  const method = current[trackedCall.method];
216
223
  const fetchPromise = method(trackedCall.options).then((res) => {
217
- if (mountedRef.current) {
218
- setCache(queryKey, {
219
- data: res.error ? void 0 : res.data,
220
- error: res.error,
221
- timestamp: Date.now(),
222
- tags: queryTags
223
- });
224
- }
224
+ setCache(queryKey, {
225
+ data: res.error ? void 0 : res.data,
226
+ error: res.error,
227
+ timestamp: Date.now(),
228
+ tags: queryTags
229
+ });
225
230
  }).catch((err) => {
226
- if (mountedRef.current) {
227
- setCache(queryKey, {
228
- data: void 0,
229
- error: err,
230
- timestamp: Date.now(),
231
- tags: queryTags
232
- });
233
- }
231
+ setCache(queryKey, {
232
+ data: void 0,
233
+ error: err,
234
+ timestamp: Date.now(),
235
+ tags: queryTags
236
+ });
234
237
  });
235
238
  setCache(queryKey, {
236
239
  promise: fetchPromise,
@@ -334,7 +337,7 @@ function useSelectorMode(config) {
334
337
  autoRevalidateRef.current = autoRevalidateTags;
335
338
  if (!triggerRef.current) {
336
339
  triggerRef.current = (async (...args) => {
337
- dispatch({ type: "FETCH_START" });
340
+ dispatch({ type: "MUTATION_START" });
338
341
  const options = args[0];
339
342
  const resolvedPath = resolvePath2(pathRef.current, options?.params);
340
343
  let res;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "enlace",
3
- "version": "0.0.1-beta.12",
3
+ "version": "0.0.1-beta.13",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"