@hyper-fetch/react 8.1.1 → 8.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.
Files changed (131) hide show
  1. package/README.md +202 -52
  2. package/__tests__/features/helpers/use-request-events/use-request-events.base.spec.ts +1 -1
  3. package/__tests__/features/helpers/use-request-events/use-request-events.utils.spec.ts +1 -1
  4. package/__tests__/features/helpers/use-socket-state/use-socket-state.base.spec.ts +3 -3
  5. package/__tests__/features/helpers/use-tracked-state/use-tacked-state.actions.spec.ts +1 -1
  6. package/__tests__/features/helpers/use-tracked-state/use-tracked-state.base.spec.ts +55 -55
  7. package/__tests__/features/helpers/use-tracked-state/use-tracked-state.utils.spec.ts +8 -9
  8. package/__tests__/features/provider/provider.hydration.spec.tsx +3 -4
  9. package/__tests__/features/provider/use-config-provider.base.spec.tsx +1 -2
  10. package/__tests__/features/use-app-manager/use-app-manager.base.spec.ts +1 -1
  11. package/__tests__/features/use-cache/use-cache.base.spec.ts +6 -6
  12. package/__tests__/features/use-cache/use-cache.typescript.spec.ts +1 -2
  13. package/__tests__/features/use-emitter/use-emitter.base.spec.ts +1 -1
  14. package/__tests__/features/use-fetch/use-fetch.base.spec.ts +13 -9
  15. package/__tests__/features/use-fetch/use-fetch.cancel.spec.ts +1 -1
  16. package/__tests__/features/use-fetch/use-fetch.clear-state.spec.ts +1 -1
  17. package/__tests__/features/use-fetch/use-fetch.concurrency.spec.ts +1 -1
  18. package/__tests__/features/use-fetch/use-fetch.debounce.spec.ts +1 -1
  19. package/__tests__/features/use-fetch/use-fetch.integration.spec.tsx +2 -2
  20. package/__tests__/features/use-fetch/use-fetch.keep-previous-data.spec.ts +1 -1
  21. package/__tests__/features/use-fetch/use-fetch.methods.spec.ts +1 -1
  22. package/__tests__/features/use-fetch/use-fetch.offline.spec.ts +1 -1
  23. package/__tests__/features/use-fetch/use-fetch.prefetch.spec.tsx +2 -2
  24. package/__tests__/features/use-fetch/use-fetch.refresh.spec.ts +3 -2
  25. package/__tests__/features/use-fetch/use-fetch.rerender.spec.tsx +3 -3
  26. package/__tests__/features/use-fetch/use-fetch.revalidate.spec.ts +47 -17
  27. package/__tests__/features/use-fetch/use-fetch.suspense.spec.tsx +4 -4
  28. package/__tests__/features/use-fetch/use-fetch.typescript.spec.ts +1 -2
  29. package/__tests__/features/use-fetch/use-fetch.utils.spec.ts +2 -2
  30. package/__tests__/features/use-fetch/use-fetch.window.spec.ts +1 -1
  31. package/__tests__/features/use-listener/use-listener.base.spec.ts +1 -1
  32. package/__tests__/features/use-queue/use-queue.actions.spec.ts +3 -3
  33. package/__tests__/features/use-queue/use-queue.base.spec.ts +13 -13
  34. package/__tests__/features/use-queue/use-queue.resolve.spec.ts +6 -6
  35. package/__tests__/features/use-stream/use-stream.base.spec.ts +1 -1
  36. package/__tests__/features/use-submit/use-submit.base.spec.ts +2 -2
  37. package/__tests__/features/use-submit/use-submit.cancel.spec.ts +1 -1
  38. package/__tests__/features/use-submit/use-submit.concurrency.spec.ts +1 -1
  39. package/__tests__/features/use-submit/use-submit.debounce.spec.ts +15 -15
  40. package/__tests__/features/use-submit/use-submit.methods.spec.ts +1 -1
  41. package/__tests__/features/use-submit/use-submit.optimistic.spec.ts +1 -1
  42. package/__tests__/features/use-submit/use-submit.queue.spec.ts +1 -1
  43. package/__tests__/features/use-submit/use-submit.retry.spec.ts +2 -2
  44. package/__tests__/features/use-submit/use-submit.revalidate.spec.ts +1 -1
  45. package/__tests__/features/use-submit/use-submit.submit.spec.ts +1 -1
  46. package/__tests__/features/use-submit/use-submit.typescript.spec.ts +2 -3
  47. package/__tests__/shared/isolation.tests.ts +1 -1
  48. package/__tests__/shared/response.tests.ts +2 -2
  49. package/__tests__/tsconfig.json +11 -17
  50. package/__tests__/utils/cache.utils.ts +6 -6
  51. package/__tests__/utils/use-app-manager.utils.ts +0 -1
  52. package/__tests__/utils/use-cache.utils.ts +0 -1
  53. package/__tests__/utils/use-emitter.utils.ts +1 -2
  54. package/__tests__/utils/use-fetch.utils.ts +0 -1
  55. package/__tests__/utils/use-listener.utils.ts +1 -2
  56. package/__tests__/utils/use-queue.utils.ts +4 -5
  57. package/__tests__/utils/use-request-events.utils.ts +0 -1
  58. package/__tests__/utils/use-socket-state.utils.ts +1 -2
  59. package/__tests__/utils/use-submit.utils.ts +0 -1
  60. package/__tests__/utils/use-tracked-state.utils.ts +0 -1
  61. package/dist/helpers/use-request-events/use-request-events.hooks.d.ts.map +1 -1
  62. package/dist/helpers/use-request-events/use-request-events.types.d.ts.map +1 -1
  63. package/dist/helpers/use-socket-state/use-socket-state.hooks.d.ts.map +1 -1
  64. package/dist/helpers/use-tracked-state/use-tracked-state.types.d.ts.map +1 -1
  65. package/dist/helpers/use-tracked-state/use-tracked-state.utils.d.ts.map +1 -1
  66. package/dist/hooks/use-app-manager/use-app-manager.hooks.d.ts +1 -0
  67. package/dist/hooks/use-app-manager/use-app-manager.hooks.d.ts.map +1 -1
  68. package/dist/hooks/use-cache/use-cache.hooks.d.ts +1 -0
  69. package/dist/hooks/use-cache/use-cache.hooks.d.ts.map +1 -1
  70. package/dist/hooks/use-cache/use-cache.types.d.ts +2 -2
  71. package/dist/hooks/use-cache/use-cache.types.d.ts.map +1 -1
  72. package/dist/hooks/use-emitter/use-emitter.hooks.d.ts +1 -0
  73. package/dist/hooks/use-emitter/use-emitter.hooks.d.ts.map +1 -1
  74. package/dist/hooks/use-emitter/use-emitter.types.d.ts +1 -0
  75. package/dist/hooks/use-emitter/use-emitter.types.d.ts.map +1 -1
  76. package/dist/hooks/use-fetch/use-fetch.constants.d.ts.map +1 -1
  77. package/dist/hooks/use-fetch/use-fetch.hooks.d.ts +2 -1
  78. package/dist/hooks/use-fetch/use-fetch.hooks.d.ts.map +1 -1
  79. package/dist/hooks/use-fetch/use-fetch.types.d.ts.map +1 -1
  80. package/dist/hooks/use-listener/use-listener.hooks.d.ts +1 -0
  81. package/dist/hooks/use-listener/use-listener.hooks.d.ts.map +1 -1
  82. package/dist/hooks/use-listener/use-listener.types.d.ts +1 -0
  83. package/dist/hooks/use-listener/use-listener.types.d.ts.map +1 -1
  84. package/dist/hooks/use-queue/use-queue.constants.d.ts.map +1 -1
  85. package/dist/hooks/use-queue/use-queue.hooks.d.ts +2 -1
  86. package/dist/hooks/use-queue/use-queue.hooks.d.ts.map +1 -1
  87. package/dist/hooks/use-queue/use-queue.types.d.ts +6 -0
  88. package/dist/hooks/use-queue/use-queue.types.d.ts.map +1 -1
  89. package/dist/hooks/use-submit/use-submit.hooks.d.ts +2 -1
  90. package/dist/hooks/use-submit/use-submit.hooks.d.ts.map +1 -1
  91. package/dist/hooks/use-submit/use-submit.types.d.ts +1 -1
  92. package/dist/hooks/use-submit/use-submit.types.d.ts.map +1 -1
  93. package/dist/index.mjs +30 -22
  94. package/dist/index.mjs.map +1 -1
  95. package/dist/provider/provider.types.d.ts +4 -4
  96. package/dist/provider/provider.types.d.ts.map +1 -1
  97. package/dist/utils/bounce.utils.d.ts.map +1 -1
  98. package/dist/utils/deep-equal.utils.d.ts +2 -2
  99. package/dist/utils/deep-equal.utils.d.ts.map +1 -1
  100. package/dist/utils/tracked-proxy.utils.d.ts +1 -1
  101. package/dist/utils/tracked-proxy.utils.d.ts.map +1 -1
  102. package/package.json +8 -13
  103. package/src/helpers/use-request-events/use-request-events.hooks.ts +4 -5
  104. package/src/helpers/use-request-events/use-request-events.types.ts +0 -1
  105. package/src/helpers/use-socket-state/use-socket-state.hooks.ts +5 -6
  106. package/src/helpers/use-tracked-state/use-tracked-state.hooks.ts +11 -11
  107. package/src/helpers/use-tracked-state/use-tracked-state.types.ts +0 -1
  108. package/src/helpers/use-tracked-state/use-tracked-state.utils.ts +12 -13
  109. package/src/hooks/use-app-manager/use-app-manager.hooks.ts +2 -2
  110. package/src/hooks/use-cache/use-cache.hooks.ts +4 -4
  111. package/src/hooks/use-cache/use-cache.types.ts +2 -3
  112. package/src/hooks/use-emitter/use-emitter.hooks.ts +4 -4
  113. package/src/hooks/use-emitter/use-emitter.types.ts +1 -0
  114. package/src/hooks/use-fetch/use-fetch.constants.ts +0 -1
  115. package/src/hooks/use-fetch/use-fetch.hooks.ts +14 -10
  116. package/src/hooks/use-fetch/use-fetch.types.ts +0 -1
  117. package/src/hooks/use-listener/use-listener.hooks.ts +3 -3
  118. package/src/hooks/use-listener/use-listener.types.ts +1 -0
  119. package/src/hooks/use-queue/use-queue.constants.ts +0 -1
  120. package/src/hooks/use-queue/use-queue.hooks.ts +3 -3
  121. package/src/hooks/use-queue/use-queue.types.ts +6 -0
  122. package/src/hooks/use-stream/use-stream.hooks.ts +4 -4
  123. package/src/hooks/use-submit/use-submit.hooks.ts +7 -7
  124. package/src/hooks/use-submit/use-submit.types.ts +1 -2
  125. package/src/provider/provider.types.ts +4 -5
  126. package/src/utils/bounce.utils.ts +1 -0
  127. package/src/utils/deep-equal.utils.ts +28 -12
  128. package/src/utils/tracked-proxy.utils.ts +1 -1
  129. package/tsconfig.json +11 -2
  130. package/vite.config.ts +14 -20
  131. package/.eslintrc.cjs +0 -12
@@ -1,11 +1,11 @@
1
1
  import { RequestInstance } from '@hyper-fetch/core';
2
- import { default as React } from 'react';
3
- import { UseSubmitOptionsType } from '../hooks/use-submit';
4
2
  import { UseCacheOptionsType } from '../hooks/use-cache';
5
- import { UseQueueOptionsType } from '../hooks/use-queue';
6
- import { UseListenerOptionsType } from '../hooks/use-listener';
7
3
  import { UseEmitterOptionsType } from '../hooks/use-emitter';
8
4
  import { UseFetchOptionsType } from '../hooks/use-fetch';
5
+ import { UseListenerOptionsType } from '../hooks/use-listener';
6
+ import { UseQueueOptionsType } from '../hooks/use-queue';
7
+ import { UseSubmitOptionsType } from '../hooks/use-submit';
8
+ import { default as React } from 'react';
9
9
  export type ProviderOptionsType = {
10
10
  useFetchConfig?: Partial<UseFetchOptionsType<RequestInstance>>;
11
11
  useSubmitConfig?: Partial<UseSubmitOptionsType<RequestInstance>>;
@@ -1 +1 @@
1
- {"version":3,"file":"provider.types.d.ts","sourceRoot":"","sources":["../../src/provider/provider.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC,CAAC;IAC/D,eAAe,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC,CAAC;IACjE,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC,CAAC;IAC/D,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC9C,UAAU,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,mBAAmB,CAAC;IAC5B,SAAS,EAAE,CAAC,SAAS,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACrD,CAAC"}
1
+ {"version":3,"file":"provider.types.d.ts","sourceRoot":"","sources":["../../src/provider/provider.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC,CAAC;IAC/D,eAAe,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC,CAAC;IACjE,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC,CAAC;IAC/D,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC9C,UAAU,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,mBAAmB,CAAC;IAC5B,SAAS,EAAE,CAAC,SAAS,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACrD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"bounce.utils.d.ts","sourceRoot":"","sources":["../../src/utils/bounce.utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,YAAY;IACxC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB,KAAG;IAAE,KAAK,EAAE,MAAM,IAAI,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAKvC,CAAC"}
1
+ {"version":3,"file":"bounce.utils.d.ts","sourceRoot":"","sources":["../../src/utils/bounce.utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,YAAY;IACxC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB,KAAG;IAAE,KAAK,EAAE,MAAM,IAAI,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAMvC,CAAC"}
@@ -3,12 +3,12 @@
3
3
  * @param value any object or primitive
4
4
  * @returns true when value is empty
5
5
  */
6
- export declare const isEmpty: (value: unknown) => boolean;
6
+ export declare const isEmpty: (value?: unknown) => boolean;
7
7
  /**
8
8
  * Allow to deep compare any passed values
9
9
  * @param firstValue unknown
10
10
  * @param secondValue unknown
11
11
  * @returns true when elements are equal
12
12
  */
13
- export declare const isEqual: (firstValue: unknown, secondValue: unknown) => boolean;
13
+ export declare const isEqual: (firstValue?: unknown, secondValue?: unknown) => boolean;
14
14
  //# sourceMappingURL=deep-equal.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deep-equal.utils.d.ts","sourceRoot":"","sources":["../../src/utils/deep-equal.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,KAAG,OAKxC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,YAAY,OAAO,EAAE,aAAa,OAAO,KAAG,OAkDnE,CAAC"}
1
+ {"version":3,"file":"deep-equal.utils.d.ts","sourceRoot":"","sources":["../../src/utils/deep-equal.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,QAAQ,OAAO,KAAG,OASzC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,aAAa,OAAO,EAAE,cAAc,OAAO,KAAG,OA8DrE,CAAC"}
@@ -3,5 +3,5 @@
3
3
  * Unlike getter-based tracking, Proxy-wrapped objects display their actual values in console.log,
4
4
  * making debugging significantly easier while preserving field-level dependency tracking.
5
5
  */
6
- export declare const createTrackedProxy: <T extends Record<string, unknown>, K extends string>(target: T, trackedKeys: ReadonlyArray<K>, setRenderKey: (key: K) => void) => T;
6
+ export declare const createTrackedProxy: <T extends Record<string, unknown>, K extends string>(target: T, trackedKeys: readonly K[], setRenderKey: (key: K) => void) => T;
7
7
  //# sourceMappingURL=tracked-proxy.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracked-proxy.utils.d.ts","sourceRoot":"","sources":["../../src/utils/tracked-proxy.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,MAAM,EACpF,QAAQ,CAAC,EACT,aAAa,aAAa,CAAC,CAAC,CAAC,EAC7B,cAAc,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,KAC7B,CASF,CAAC"}
1
+ {"version":3,"file":"tracked-proxy.utils.d.ts","sourceRoot":"","sources":["../../src/utils/tracked-proxy.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,MAAM,EACpF,QAAQ,CAAC,EACT,aAAa,SAAS,CAAC,EAAE,EACzB,cAAc,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,KAC7B,CASF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyper-fetch/react",
3
- "version": "8.1.1",
3
+ "version": "8.2.2",
4
4
  "description": "React hooks and utils for the hyper-fetch",
5
5
  "author": "Maciej Pyrc <maciekpyrc@gmail.com>, Kacper Skawina <kacper.skawina@gmail.com>",
6
6
  "homepage": "https://hyperfetch.bettertyped.com/",
@@ -23,13 +23,13 @@
23
23
  },
24
24
  "scripts": {
25
25
  "test": "vitest run",
26
- "start": "yarn build && npx run-when-changed --watch 'src/**/*.ts' --exec 'yarn build'",
26
+ "start": "pnpm build && npx run-when-changed --watch 'src/**/*.ts' --exec 'pnpm build'",
27
27
  "build": "vite build",
28
- "lint": "eslint . --fix",
29
- "format": "prettier --write .",
30
- "typecheck": "tsc --noEmit --emitDeclarationOnly false && tsc --noEmit -p __tests__/tsconfig.json",
31
- "tests": "yarn lint-staged",
32
- "release": "yarn semantic-release --extends ../../release.config.js -t 'react-hyper-fetch-v${version}'"
28
+ "lint": "oxlint .",
29
+ "format": "oxfmt --write .",
30
+ "typecheck": "tsgo --noEmit --emitDeclarationOnly false && tsgo --noEmit -p __tests__/tsconfig.json",
31
+ "tests": "pnpm lint-staged",
32
+ "release": "pnpm semantic-release --extends ../../release.config.js -t 'react-hyper-fetch-v${version}'"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@hyper-fetch/core": "*",
@@ -50,14 +50,9 @@
50
50
  "vitest related --run --passWithNoTests"
51
51
  ]
52
52
  },
53
- "eslintConfig": {
54
- "extends": [
55
- "react"
56
- ]
57
- },
58
53
  "publishConfig": {
59
54
  "access": "public",
60
- "registry": "https://registry.npmjs.com/"
55
+ "registry": "https://registry.npmjs.org/"
61
56
  },
62
57
  "repository": {
63
58
  "type": "git",
@@ -1,3 +1,4 @@
1
+ import { useWillUnmount } from "@better-hooks/lifecycle";
1
2
  import type {
2
3
  ExtractErrorType,
3
4
  ExtractResponseType,
@@ -11,9 +12,6 @@ import type {
11
12
  OptimisticCallbackResult,
12
13
  } from "@hyper-fetch/core";
13
14
  import { scopeKey } from "@hyper-fetch/core";
14
- import { useWillUnmount } from "@better-hooks/lifecycle";
15
- import { useRef } from "react";
16
-
17
15
  import type {
18
16
  OnErrorCallbackType,
19
17
  OnStartCallbackType,
@@ -25,6 +23,7 @@ import type {
25
23
  UseRequestEventsPropsType,
26
24
  UseRequestEventsLifecycleMap,
27
25
  } from "helpers";
26
+ import { useRef } from "react";
28
27
 
29
28
  /**
30
29
  * This is helper hook that handles main Hyper-Fetch event/data flow
@@ -73,7 +72,7 @@ export const useRequestEvents = <R extends RequestInstance>({
73
72
 
74
73
  const clearLifecycleListeners = () => {
75
74
  const events = lifecycleEvents.current;
76
- const listeners = Array.from(events.values());
75
+ const listeners = [...events.values()];
77
76
  listeners.forEach((value) => {
78
77
  value.unmount();
79
78
  });
@@ -140,7 +139,7 @@ export const useRequestEvents = <R extends RequestInstance>({
140
139
 
141
140
  // When we process the cache data, we don't want to change the loading state during it
142
141
  // This prevents the UI from flickering with { data: null, loading: false }
143
- if (isProcessing) return;
142
+ if (isProcessing) {return;}
144
143
 
145
144
  const canDisableLoading = !loading && !dispatcher.hasRunningRequests(scopeKey(req.queryKey, req.scope));
146
145
  if (loading || canDisableLoading) {
@@ -15,7 +15,6 @@ import type {
15
15
  ResponseType,
16
16
  ResponseSuccessType,
17
17
  } from "@hyper-fetch/core";
18
-
19
18
  import type { UseTrackedStateActions } from "helpers";
20
19
 
21
20
  // Misc
@@ -1,8 +1,7 @@
1
- import type { SocketInstance, ExtractSocketExtraType } from "@hyper-fetch/sockets";
2
1
  import { useDidMount, useDidUpdate } from "@better-hooks/lifecycle";
3
- import { useCallback, useRef, useSyncExternalStore } from "react";
4
-
2
+ import type { SocketInstance, ExtractSocketExtraType } from "@hyper-fetch/sockets";
5
3
  import type { UseSocketStateType, UseSocketStateProps } from "helpers";
4
+ import { useCallback, useRef, useSyncExternalStore } from "react";
6
5
 
7
6
  export const useSocketState = <DataType, Socket extends SocketInstance>(
8
7
  socket: Socket,
@@ -22,7 +21,7 @@ export const useSocketState = <DataType, Socket extends SocketInstance>(
22
21
  connecting: socket.adapter.connecting,
23
22
  timestamp: null,
24
23
  });
25
- const renderKeys = useRef<Array<keyof UseSocketStateType<Socket, DataType>>>([]);
24
+ const renderKeys = useRef<(keyof UseSocketStateType<Socket, DataType>)[]>([]);
26
25
 
27
26
  // ******************
28
27
  // useSyncExternalStore
@@ -51,9 +50,9 @@ export const useSocketState = <DataType, Socket extends SocketInstance>(
51
50
  // Dependency Tracking
52
51
  // ******************
53
52
 
54
- const renderKeyTrigger = (keys: Array<keyof UseSocketStateType<Socket, DataType>>) => {
53
+ const renderKeyTrigger = (keys: (keyof UseSocketStateType<Socket, DataType>)[]) => {
55
54
  const shouldRerender = renderKeys.current.some((renderKey) => keys.includes(renderKey));
56
- if (shouldRerender) emitChange();
55
+ if (shouldRerender) {emitChange();}
57
56
  };
58
57
 
59
58
  const setRenderKey = (renderKey: keyof UseSocketStateType<Socket, DataType>) => {
@@ -11,8 +11,8 @@ import type {
11
11
  } from "@hyper-fetch/core";
12
12
  import { scopeKey } from "@hyper-fetch/core";
13
13
  import { useCallback, useRef, useSyncExternalStore } from "react";
14
-
15
14
  import { isEqual } from "utils";
15
+
16
16
  import type {
17
17
  UseTrackedStateActions,
18
18
  UseTrackedStateType,
@@ -49,7 +49,7 @@ export const useTrackedState = <T extends RequestInstance>({
49
49
  const { cache } = client;
50
50
 
51
51
  const state = useRef<UseTrackedStateType<T>>(getInitialState({ initialResponse, dispatcher, request, disabled }));
52
- const renderKeys = useRef<Array<keyof UseTrackedStateType<T>>>([]);
52
+ const renderKeys = useRef<(keyof UseTrackedStateType<T>)[]>([]);
53
53
  const isProcessingData = useRef("");
54
54
  const previousCacheKey = useRef(cacheKey);
55
55
 
@@ -89,9 +89,9 @@ export const useTrackedState = <T extends RequestInstance>({
89
89
  // Dependency Tracking
90
90
  // ******************
91
91
 
92
- const renderKeyTrigger = (keys: Array<keyof UseTrackedStateType>) => {
92
+ const renderKeyTrigger = (keys: (keyof UseTrackedStateType)[]) => {
93
93
  const shouldRerender = renderKeys.current.some((renderKey) => keys.includes(renderKey));
94
- if (shouldRerender) emitChange();
94
+ if (shouldRerender) {emitChange();}
95
95
  };
96
96
 
97
97
  const setRenderKey = (renderKey: keyof UseTrackedStateType) => {
@@ -264,37 +264,37 @@ export const useTrackedState = <T extends RequestInstance>({
264
264
  },
265
265
  setLoading: (loading) => {
266
266
  const value = loading instanceof Function ? loading(state.current.loading) : loading;
267
- if (value === state.current.loading) return;
267
+ if (value === state.current.loading) {return;}
268
268
  state.current.loading = value;
269
269
  renderKeyTrigger(["loading"]);
270
270
  },
271
271
  setStatus: (status) => {
272
272
  const value = status instanceof Function ? status(state.current.status) : status;
273
- if (value === state.current.status) return;
273
+ if (value === state.current.status) {return;}
274
274
  state.current.status = status instanceof Function ? status(state.current.status || null) : status;
275
275
  renderKeyTrigger(["status"]);
276
276
  },
277
277
  setSuccess: (success) => {
278
278
  const value = success instanceof Function ? success(state.current.success || false) : success;
279
- if (value === state.current.success) return;
279
+ if (value === state.current.success) {return;}
280
280
  state.current.success = success instanceof Function ? success(state.current.success || false) : success;
281
281
  renderKeyTrigger(["success"]);
282
282
  },
283
283
  setExtra: (extra) => {
284
284
  const value = extra instanceof Function ? extra(state.current.extra) : extra;
285
- if (value === state.current.extra) return;
285
+ if (value === state.current.extra) {return;}
286
286
  state.current.extra = extra instanceof Function ? extra(state.current.extra) : extra;
287
287
  renderKeyTrigger(["extra"]);
288
288
  },
289
289
  setRetries: (retries) => {
290
290
  const value = retries instanceof Function ? retries(state.current.retries || 0) : retries;
291
- if (value === state.current.retries) return;
291
+ if (value === state.current.retries) {return;}
292
292
  state.current.retries = retries instanceof Function ? retries(state.current.retries || 0) : retries;
293
293
  renderKeyTrigger(["retries"]);
294
294
  },
295
295
  setResponseTimestamp: (timestamp) => {
296
296
  const value = timestamp instanceof Function ? timestamp(state.current.responseTimestamp) : timestamp;
297
- if (value === state.current.responseTimestamp) return;
297
+ if (value === state.current.responseTimestamp) {return;}
298
298
  const getTimestamp = (prev: Date | null) => {
299
299
  return timestamp instanceof Function ? timestamp(prev ? new Date(prev) : null) : timestamp;
300
300
  };
@@ -304,7 +304,7 @@ export const useTrackedState = <T extends RequestInstance>({
304
304
  },
305
305
  setRequestTimestamp: (timestamp) => {
306
306
  const value = timestamp instanceof Function ? timestamp(state.current.requestTimestamp) : timestamp;
307
- if (value === state.current.requestTimestamp) return;
307
+ if (value === state.current.requestTimestamp) {return;}
308
308
  const getTimestamp = (prev: Date | null) => {
309
309
  return timestamp instanceof Function ? timestamp(prev ? new Date(prev) : null) : timestamp;
310
310
  };
@@ -12,7 +12,6 @@ import type {
12
12
  CacheSetState,
13
13
  LoggerMethods,
14
14
  } from "@hyper-fetch/core";
15
-
16
15
  import type { isEqual } from "utils";
17
16
 
18
17
  export type UseTrackedStateProps<T extends RequestInstance> = {
@@ -14,7 +14,6 @@ import type {
14
14
  ResponseType,
15
15
  } from "@hyper-fetch/core";
16
16
  import { scopeKey } from "@hyper-fetch/core";
17
-
18
17
  import type { UseTrackedStateType } from "helpers";
19
18
  import { initialState } from "helpers";
20
19
 
@@ -24,7 +23,7 @@ import { initialState } from "helpers";
24
23
  */
25
24
  const getCacheKeyIdentity = (cacheKey: string): string => {
26
25
  const lastUnderscoreIndex = cacheKey.lastIndexOf("_");
27
- if (lastUnderscoreIndex === -1) return cacheKey;
26
+ if (lastUnderscoreIndex === -1) {return cacheKey;}
28
27
  return cacheKey.substring(0, lastUnderscoreIndex);
29
28
  };
30
29
 
@@ -40,10 +39,10 @@ export const getShouldClearState = (
40
39
  oldCacheKey: string,
41
40
  newCacheKey: string,
42
41
  ): boolean => {
43
- if (oldCacheKey === newCacheKey) return false;
42
+ if (oldCacheKey === newCacheKey) {return false;}
44
43
 
45
- if (mode === "clean") return true;
46
- if (mode === "preserve") return false;
44
+ if (mode === "clean") {return true;}
45
+ if (mode === "preserve") {return false;}
47
46
 
48
47
  // "auto" — compare the identity part (method + endpoint with params)
49
48
  return getCacheKeyIdentity(oldCacheKey) !== getCacheKeyIdentity(newCacheKey);
@@ -58,17 +57,17 @@ export const getDetailsState = (
58
57
  isCanceled: false,
59
58
  isOffline: false,
60
59
  willRetry: false,
61
- addedTimestamp: +new Date(),
62
- triggerTimestamp: +new Date(),
63
- requestTimestamp: +new Date(),
64
- responseTimestamp: +new Date(),
60
+ addedTimestamp: Date.now(),
61
+ triggerTimestamp: Date.now(),
62
+ requestTimestamp: Date.now(),
63
+ responseTimestamp: Date.now(),
65
64
  ...details,
66
65
  };
67
66
  };
68
67
 
69
68
  export const isStaleCacheData = (staleTime: number, staleTimestamp: NullableType<Date | number>) => {
70
- if (!staleTimestamp) return true;
71
- return +new Date() > +staleTimestamp + staleTime;
69
+ if (!staleTimestamp) {return true;}
70
+ return Date.now() > +staleTimestamp + staleTime;
72
71
  };
73
72
 
74
73
  export const getValidCacheData = <T extends RequestInstance>(
@@ -95,8 +94,8 @@ export const getValidCacheData = <T extends RequestInstance>(
95
94
  cacheKey: request.cacheKey,
96
95
  scope: request.scope,
97
96
  cacheTime: request.cacheTime,
98
- requestTimestamp: initialResponse?.requestTimestamp ?? +new Date(),
99
- responseTimestamp: initialResponse?.responseTimestamp ?? +new Date(),
97
+ requestTimestamp: initialResponse?.requestTimestamp ?? Date.now(),
98
+ responseTimestamp: initialResponse?.responseTimestamp ?? Date.now(),
100
99
  };
101
100
  }
102
101
 
@@ -1,9 +1,9 @@
1
1
  import { useDidMount } from "@better-hooks/lifecycle";
2
2
  import type { ClientInstance } from "@hyper-fetch/core";
3
- import { useState } from "react";
4
-
5
3
  import type { UseAppManagerReturnType } from "hooks/use-app-manager";
4
+ import { useState } from "react";
6
5
 
6
+ /** Track the application's online/offline and focus/blur state through the client's AppManager. */
7
7
  export const useAppManager = <Client extends ClientInstance>(client: Client): UseAppManagerReturnType => {
8
8
  const [online, setIsOnline] = useState(client.appManager.isOnline);
9
9
  const [focused, setIsFocused] = useState(client.appManager.isFocused);
@@ -1,14 +1,14 @@
1
1
  import { useDidUpdate } from "@better-hooks/lifecycle";
2
2
  import type { RequestInstance } from "@hyper-fetch/core";
3
3
  import { getRequestDispatcher } from "@hyper-fetch/core";
4
- import { useRef } from "react";
5
-
4
+ import { useRequestEvents, useTrackedState } from "helpers";
6
5
  import type { UseCacheOptionsType, UseCacheReturnType } from "hooks/use-cache";
7
6
  import { useCacheDefaultOptions } from "hooks/use-cache";
8
- import { useRequestEvents, useTrackedState } from "helpers";
9
7
  import { useProvider } from "provider";
8
+ import { useRef } from "react";
10
9
  import { createTrackedProxy } from "utils";
11
10
 
11
+ /** Subscribe to cache updates for a given request without triggering network activity. */
12
12
  export const useCache = <T extends RequestInstance>(
13
13
  request: T,
14
14
  options?: UseCacheOptionsType<T>,
@@ -71,7 +71,7 @@ export const useCache = <T extends RequestInstance>(
71
71
  true,
72
72
  );
73
73
 
74
- const invalidate = (cacheKeys?: string | RegExp | RequestInstance | Array<string | RegExp | RequestInstance>) => {
74
+ const invalidate = (cacheKeys?: string | RegExp | RequestInstance | (string | RegExp | RequestInstance)[]) => {
75
75
  cache.invalidate(cacheKeys ?? cacheKey);
76
76
  };
77
77
 
@@ -1,7 +1,6 @@
1
1
  import type { RequestInstance, ExtractResponseType, ExtractErrorType, CacheValueType } from "@hyper-fetch/core";
2
-
3
- import type { isEqual } from "utils";
4
2
  import type { UseTrackedStateActions, UseTrackedStateType } from "helpers";
3
+ import type { isEqual } from "utils";
5
4
 
6
5
  export type UseCacheOptionsType<T extends RequestInstance> = {
7
6
  /**
@@ -23,5 +22,5 @@ export type UseCacheReturnType<T extends RequestInstance> = UseTrackedStateType<
23
22
  /**
24
23
  * Invalidate cache for the current request or pass custom key to trigger it by invalidationKey(Regex / cacheKey).
25
24
  */
26
- invalidate: (cacheKeys?: string | RegExp | RequestInstance | Array<string | RegExp | RequestInstance>) => void;
25
+ invalidate: (cacheKeys?: string | RegExp | RequestInstance | (string | RegExp | RequestInstance)[]) => void;
27
26
  };
@@ -1,12 +1,12 @@
1
- import type { EmitterInstance, EmitterCallbackErrorType, EmitType } from "@hyper-fetch/sockets";
2
1
  import { useDidUpdate } from "@better-hooks/lifecycle";
3
- import { useRef } from "react";
4
-
5
- import type { UseEmitterOptionsType } from "hooks/use-emitter";
2
+ import type { EmitterInstance, EmitterCallbackErrorType, EmitType } from "@hyper-fetch/sockets";
6
3
  import { useSocketState } from "helpers";
4
+ import type { UseEmitterOptionsType } from "hooks/use-emitter";
7
5
  import { useProvider } from "provider";
6
+ import { useRef } from "react";
8
7
  import { createTrackedProxy } from "utils";
9
8
 
9
+ /** Send messages through a socket emitter with tracked connection state and lifecycle callbacks. */
10
10
  export const useEmitter = <EmitterType extends EmitterInstance>(
11
11
  emitter: EmitterType,
12
12
  options?: UseEmitterOptionsType,
@@ -1,3 +1,4 @@
1
1
  export type UseEmitterOptionsType = {
2
+ /** When true (default), only re-renders when accessed state properties change */
2
3
  dependencyTracking?: boolean;
3
4
  };
@@ -1,6 +1,5 @@
1
1
  import type { RequestInstance, RequiredKeys } from "@hyper-fetch/core";
2
2
  import { Time } from "@hyper-fetch/core";
3
-
4
3
  import type { UseFetchOptionsType } from "hooks/use-fetch";
5
4
 
6
5
  type DefaultOptionsType = RequiredKeys<Omit<UseFetchOptionsType<RequestInstance>, "initialResponse">> & {
@@ -7,12 +7,11 @@ import type {
7
7
  ExtractAdapterExtraType,
8
8
  } from "@hyper-fetch/core";
9
9
  import { scopeKey } from "@hyper-fetch/core";
10
- import { useRef } from "react";
11
-
12
10
  import { useRequestEvents, useTrackedState } from "helpers";
13
11
  import type { UseFetchOptionsType, UseFetchReturnType } from "hooks/use-fetch";
14
12
  import { useFetchDefaultOptions } from "hooks/use-fetch";
15
13
  import { useProvider } from "provider";
14
+ import { useRef } from "react";
16
15
  import { createTrackedProxy, getBounceData } from "utils";
17
16
 
18
17
  type SuspenseEntry = { promise: Promise<void>; resolve: () => void; cleanup: () => void };
@@ -20,7 +19,8 @@ const suspensePromiseMap = new Map<string, SuspenseEntry>();
20
19
  const suspenseResultMap = new Map<string, { data: any; error: any; status: any; extra: any; success: boolean }>();
21
20
 
22
21
  /**
23
- * This hooks aims to retrieve data from server.
22
+ * This hook aims to retrieve data from the server. It automatically fetches on mount and
23
+ * refetches based on dependencies, with support for caching, polling, and suspense.
24
24
  * @param request Request instance
25
25
  * @param options Hook options
26
26
  * @returns
@@ -101,10 +101,14 @@ export const useFetch = <R extends RequestInstance>(
101
101
  // ******************
102
102
  // Fetching
103
103
  // ******************
104
- const handleFetch = () => {
104
+ const handleFetch = (options?: { force?: boolean }) => {
105
105
  if (!disabled) {
106
106
  logger.debug({ title: `Fetching data`, type: "system", extra: { request } });
107
- dispatcher.add(request as unknown as R);
107
+ // A forced fetch must not be deduplicated into an already running request: that request
108
+ // started earlier, so its response can be older than the state that prompted the call.
109
+ // Manual refetch() promises data at least as fresh as the moment it was called.
110
+ const requestToAdd = options?.force ? request.setDeduplicate(false) : request;
111
+ dispatcher.add(requestToAdd as unknown as R);
108
112
  } else {
109
113
  logger.debug({ title: `Cannot add to fetch queue`, type: "system", extra: { disabled } });
110
114
  }
@@ -142,7 +146,7 @@ export const useFetch = <R extends RequestInstance>(
142
146
  }
143
147
 
144
148
  const refetch = () => {
145
- handleFetch();
149
+ handleFetch({ force: true });
146
150
  handleRefresh();
147
151
  };
148
152
 
@@ -269,10 +273,10 @@ export const useFetch = <R extends RequestInstance>(
269
273
  const suspenseResult = suspenseResultMap.get(cacheKey);
270
274
  if (suspenseResult) {
271
275
  suspenseResultMap.delete(cacheKey);
272
- if (suspenseResult.data !== null) state.data = suspenseResult.data;
273
- if (suspenseResult.error !== null) state.error = suspenseResult.error;
274
- if (suspenseResult.status !== null) state.status = suspenseResult.status;
275
- if (suspenseResult.extra !== null) state.extra = suspenseResult.extra;
276
+ if (suspenseResult.data !== null) {state.data = suspenseResult.data;}
277
+ if (suspenseResult.error !== null) {state.error = suspenseResult.error;}
278
+ if (suspenseResult.status !== null) {state.status = suspenseResult.status;}
279
+ if (suspenseResult.extra !== null) {state.extra = suspenseResult.extra;}
276
280
  state.success = suspenseResult.success;
277
281
  }
278
282
 
@@ -1,5 +1,4 @@
1
1
  import type { RequestInstance, NullableType, ExtractAdapterResolvedType } from "@hyper-fetch/core";
2
-
3
2
  import type { UseRequestEventsActionsType, UseTrackedStateActions, UseTrackedStateType } from "helpers";
4
3
  import type { isEqual } from "utils";
5
4
 
@@ -1,12 +1,12 @@
1
1
  import { useDidUpdate, useWillUnmount } from "@better-hooks/lifecycle";
2
2
  import type { ListenerInstance, ExtractListenerResponseType } from "@hyper-fetch/sockets";
3
- import { useRef } from "react";
4
-
5
3
  import { useSocketState } from "helpers";
6
4
  import type { UseListenerOptionsType } from "hooks/use-listener";
7
5
  import { useProvider } from "provider";
6
+ import { useRef } from "react";
8
7
  import { createTrackedProxy } from "utils";
9
8
 
9
+ /** Subscribe to incoming socket messages on a given listener topic with tracked connection state and callbacks. */
10
10
  export const useListener = <ListenerType extends ListenerInstance>(
11
11
  listener: ListenerType,
12
12
  options?: UseListenerOptionsType,
@@ -38,7 +38,7 @@ export const useListener = <ListenerType extends ListenerInstance>(
38
38
  onEventCallback.current?.({ data, extra });
39
39
  actions.setData(data);
40
40
  actions.setExtra(extra);
41
- actions.setTimestamp(+new Date());
41
+ actions.setTimestamp(Date.now());
42
42
  });
43
43
  };
44
44
 
@@ -1,3 +1,4 @@
1
1
  export type UseListenerOptionsType = {
2
+ /** When true (default), only re-renders when accessed state properties change */
2
3
  dependencyTracking?: boolean;
3
4
  };
@@ -1,5 +1,4 @@
1
1
  import type { RequiredKeys } from "@hyper-fetch/core";
2
-
3
2
  import type { UseQueueOptionsType } from "hooks/use-queue";
4
3
 
5
4
  export const useQueueDefaultOptions: RequiredKeys<UseQueueOptionsType> = {
@@ -1,10 +1,9 @@
1
1
  import type { RequestInstance, ResolvedQueueItemType, QueueDataType, QueueItemType } from "@hyper-fetch/core";
2
2
  import { Request, getRequestDispatcher, scopeKey } from "@hyper-fetch/core";
3
- import { useState, useEffect, useCallback } from "react";
4
-
5
3
  import type { UseQueueOptionsType, QueueRequest, UseQueueReturnType } from "hooks/use-queue";
6
4
  import { useQueueDefaultOptions } from "hooks/use-queue";
7
5
  import { useProvider } from "provider";
6
+ import { useState, useEffect, useCallback } from "react";
8
7
 
9
8
  const canUpdate = (
10
9
  item: Pick<QueueRequest<RequestInstance>, "success" | "failed" | "canceled" | "removed" | "resolved">,
@@ -16,7 +15,8 @@ const canUpdate = (
16
15
  };
17
16
 
18
17
  /**
19
- * This hook allows to control dispatchers request queues
18
+ * This hook allows you to monitor and control dispatcher request queues for a given request,
19
+ * including starting, stopping, pausing, and inspecting pending/in-flight items.
20
20
  * @param request
21
21
  * @param options
22
22
  * @returns
@@ -7,14 +7,20 @@ import type {
7
7
  } from "@hyper-fetch/core";
8
8
 
9
9
  export type UseQueueOptionsType = {
10
+ /** Which dispatcher to use: "auto" picks based on request method, "fetch" or "submit" forces a specific one */
10
11
  dispatcherType?: "auto" | "fetch" | "submit";
12
+ /** When true, completed requests remain in the queue list for inspection */
11
13
  keepFinishedRequests?: boolean;
12
14
  };
13
15
 
14
16
  export type QueueRequest<Request extends RequestInstance> = ResolvedQueueItemType<Request> & {
17
+ /** Whether the request has failed after all retry attempts */
15
18
  failed?: boolean;
19
+ /** Whether the request was canceled before completing */
16
20
  canceled?: boolean;
21
+ /** Whether the request was removed from the queue */
17
22
  removed?: boolean;
23
+ /** Whether the request completed successfully */
18
24
  success?: boolean;
19
25
  /**
20
26
  * Uploading progress for given request
@@ -70,7 +70,7 @@ export const useStream = <T extends RequestInstance>(
70
70
  while (true) {
71
71
  // eslint-disable-next-line no-await-in-loop
72
72
  const { done, value } = await reader.read();
73
- if (done) break;
73
+ if (done) {break;}
74
74
 
75
75
  state.current.chunks = [...state.current.chunks, value];
76
76
  state.current.text += decoder.decode(value, { stream: true });
@@ -80,15 +80,15 @@ export const useStream = <T extends RequestInstance>(
80
80
  state.current.streaming = false;
81
81
  state.current.done = true;
82
82
  emitChange();
83
- } catch (err) {
83
+ } catch (error) {
84
84
  state.current.streaming = false;
85
- state.current.error = err as ExtractErrorType<T>;
85
+ state.current.error = error as ExtractErrorType<T>;
86
86
  emitChange();
87
87
  }
88
88
  };
89
89
 
90
90
  const start = useCallback(() => {
91
- if (state.current.streaming) return;
91
+ if (state.current.streaming) {return;}
92
92
 
93
93
  state.current = {
94
94
  ...getInitialState<T>(),