@hyper-fetch/react 8.1.0 → 8.2.0

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 (38) hide show
  1. package/README.md +191 -51
  2. package/__tests__/features/helpers/use-tracked-state/use-tracked-state.utils.spec.ts +15 -0
  3. package/__tests__/features/use-fetch/use-fetch.base.spec.ts +3 -3
  4. package/dist/helpers/use-tracked-state/use-tracked-state.utils.d.ts.map +1 -1
  5. package/dist/hooks/use-app-manager/use-app-manager.hooks.d.ts +1 -0
  6. package/dist/hooks/use-app-manager/use-app-manager.hooks.d.ts.map +1 -1
  7. package/dist/hooks/use-cache/use-cache.hooks.d.ts +1 -0
  8. package/dist/hooks/use-cache/use-cache.hooks.d.ts.map +1 -1
  9. package/dist/hooks/use-emitter/use-emitter.hooks.d.ts +1 -0
  10. package/dist/hooks/use-emitter/use-emitter.hooks.d.ts.map +1 -1
  11. package/dist/hooks/use-emitter/use-emitter.types.d.ts +1 -0
  12. package/dist/hooks/use-emitter/use-emitter.types.d.ts.map +1 -1
  13. package/dist/hooks/use-fetch/use-fetch.hooks.d.ts +2 -1
  14. package/dist/hooks/use-fetch/use-fetch.hooks.d.ts.map +1 -1
  15. package/dist/hooks/use-listener/use-listener.hooks.d.ts +1 -0
  16. package/dist/hooks/use-listener/use-listener.hooks.d.ts.map +1 -1
  17. package/dist/hooks/use-listener/use-listener.types.d.ts +1 -0
  18. package/dist/hooks/use-listener/use-listener.types.d.ts.map +1 -1
  19. package/dist/hooks/use-queue/use-queue.hooks.d.ts +2 -1
  20. package/dist/hooks/use-queue/use-queue.hooks.d.ts.map +1 -1
  21. package/dist/hooks/use-queue/use-queue.types.d.ts +6 -0
  22. package/dist/hooks/use-queue/use-queue.types.d.ts.map +1 -1
  23. package/dist/hooks/use-submit/use-submit.hooks.d.ts +2 -1
  24. package/dist/hooks/use-submit/use-submit.hooks.d.ts.map +1 -1
  25. package/dist/index.mjs +11 -4
  26. package/dist/index.mjs.map +1 -1
  27. package/package.json +1 -1
  28. package/src/helpers/use-tracked-state/use-tracked-state.utils.ts +1 -3
  29. package/src/hooks/use-app-manager/use-app-manager.hooks.ts +1 -0
  30. package/src/hooks/use-cache/use-cache.hooks.ts +1 -0
  31. package/src/hooks/use-emitter/use-emitter.hooks.ts +1 -0
  32. package/src/hooks/use-emitter/use-emitter.types.ts +1 -0
  33. package/src/hooks/use-fetch/use-fetch.hooks.ts +2 -1
  34. package/src/hooks/use-listener/use-listener.hooks.ts +1 -0
  35. package/src/hooks/use-listener/use-listener.types.ts +1 -0
  36. package/src/hooks/use-queue/use-queue.hooks.ts +2 -1
  37. package/src/hooks/use-queue/use-queue.types.ts +6 -0
  38. package/src/hooks/use-submit/use-submit.hooks.ts +2 -1
package/README.md CHANGED
@@ -1,6 +1,10 @@
1
- # ⚛️ React Hyper Fetch
1
+ # ⚛️ Hyper Fetch React
2
2
 
3
- <p>
3
+ <p align="center">
4
+ <b>React hooks for HyperFetch. Automatic fetching, caching, and real-time updates with full type safety.</b>
5
+ </p>
6
+
7
+ <p align="center">
4
8
  <a href="https://bettertyped.com/">
5
9
  <img src="https://custom-icon-badges.demolab.com/static/v1?label=&message=BetterTyped&color=333&logo=BT" />
6
10
  </a>
@@ -13,60 +17,196 @@
13
17
  <a href="https://www.npmjs.com/package/@hyper-fetch/react">
14
18
  <img src="https://custom-icon-badges.demolab.com/npm/v/@hyper-fetch/react.svg?logo=npm&color=e76f51" />
15
19
  </a>
20
+ <a href="https://www.npmjs.com/package/@hyper-fetch/react">
21
+ <img src="https://custom-icon-badges.demolab.com/npm/dm/@hyper-fetch/react?logoColor=fff&logo=trending-up" />
22
+ </a>
16
23
  <a href="https://github.com/BetterTyped/hyper-fetch">
17
24
  <img src="https://custom-icon-badges.demolab.com/badge/typescript-%23007ACC.svg?logo=typescript&logoColor=white" />
18
25
  </a>
19
- <a href="https://www.npmjs.com/package/@hyper-fetch/react">
26
+ <a href="https://bundlephobia.com/package/@hyper-fetch/react">
20
27
  <img src="https://custom-icon-badges.demolab.com/bundlephobia/minzip/@hyper-fetch/react?color=64BC4B&logo=package" />
21
28
  </a>
22
29
  </p>
23
30
 
24
- ## About
25
-
26
- **`React Hyper Fetch`** is a set of hooks for Hyper Fetch. Combined with React's lifecycle it allow to `create modern`,
27
- `optimized`, `maintainable` and `high quality solutions`. We offer many hooks for your use, thanks to which you can
28
- fetch or mutate data, observe sent requests and interact with data in the cache.
29
-
30
- ## Key Features
31
-
32
- 🔮 **Simple setup** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/basic/setup)
33
-
34
- 🎯 **Request cancellation** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/advanced/cancellation)
35
-
36
- ✨ **Window Focus/Blur Events** -
37
- [Read more](https://hyperfetch.bettertyped.com/docs/guides/react/core/window-focus-blur)
38
-
39
- 🚀 **Queueing** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/advanced/queueing)
40
-
41
- 💎 **Automatic caching** - [Read more](https://hyperfetch.bettertyped.com/docs/core/cache)
42
-
43
- 🪄 **Persistence** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/advanced/persistence)
44
-
45
- 🎊 **SSR Support** - [Read more](https://hyperfetch.bettertyped.com/docs/getting-started/environment)
46
-
47
- 🔋 **Offline First** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/advanced/offline)
48
-
49
- 📡 **Built-in adapter** - [Read more](https://hyperfetch.bettertyped.com/docs/core/adapter)
50
-
51
- 🧪 **Easy to test** - [Read more](https://hyperfetch.bettertyped.com/docs/getting-started/testing)
52
-
53
- 🎟 **Authentication** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/basic/authentication)
54
-
55
- 💡 **Prefetching** - [Read more](https://hyperfetch.bettertyped.com/docs/guides/advanced/prefetching)
56
-
57
- ## Help me keep working on this project ❤️
58
-
59
- - [Become a Sponsor on GitHub](https://github.com/sponsors/prc5)
60
-
61
- ## Sources
62
-
63
- - #### [Installation](https://hyperfetch.bettertyped.com/docs/getting-started/installation)
64
- - #### [Docs](https://hyperfetch.bettertyped.com/docs/react/overview)
65
- - #### [API](https://hyperfetch.bettertyped.com/api/)
66
- - #### [NPM](https://www.npmjs.com/package/@hyper-fetch/react)
67
- - #### [Guides](https://hyperfetch.bettertyped.com/guides/basic/setup)
68
-
69
- ## Other Packages
31
+ ## 📖 About
70
32
 
71
- - - #### [Hyper Fetch](https://github.com/BetterTyped/hyper-fetch/tree/main/packages/core)
72
- - #### [Hyper Fetch Sockets](https://github.com/BetterTyped/hyper-fetch/tree/main/packages/sockets)
33
+ `@hyper-fetch/react` connects HyperFetch's typed request system to React's component lifecycle. `useFetch` triggers requests on mount and re-fetches when dependencies change. `useSubmit` gives you a `submit` function for mutations triggered by user actions. Both hooks return fully typed `data`, `error`, and loading states with built-in callbacks.
34
+
35
+ ## 🎯 Key Capabilities
36
+
37
+ - ⚡ **Data on mount, zero boilerplate** — `useFetch` fetches, caches, and types your data automatically
38
+ - 🎯 **Mutations that just work** — `useSubmit` handles loading, errors, and success states for form submissions
39
+ - 🔄 **Always fresh data** — Auto-refetch on window focus, polling, and stale-time revalidation built in
40
+ - ✨ **Optimistic updates with rollback** — Update the UI instantly and auto-revert if the request fails
41
+ - 🔮 **Full type safety** — Every hook, callback, response, and error is typed end-to-end with zero `any`
42
+ - 🚀 **Instant page loads** — Prefetch data before components mount so users never wait
43
+ - 🔗 **No more useEffect spaghetti** — Dependent requests via `disabled` option, no manual orchestration
44
+ - 📡 **SSR out of the box** — Works with Next.js, Remix, and any server-rendered framework
45
+ - 💎 **Skip the state library** — No Redux or Zustand needed for server state — it's all handled
46
+
47
+ ## 🚀 Quick Start
48
+
49
+ ```bash
50
+ npm install @hyper-fetch/core @hyper-fetch/react
51
+ ```
52
+
53
+ ```tsx
54
+ import { useFetch } from "@hyper-fetch/react";
55
+ import { getUsers } from "./api";
56
+
57
+ const UserList = () => {
58
+ // Fetches on mount, returns typed data — no useEffect needed
59
+ const { data, loading, error } = useFetch(getUsers);
60
+
61
+ if (loading) return <p>Loading...</p>;
62
+ if (error) return <p>Something went wrong</p>;
63
+ return <ul>{data?.map((user) => <li key={user.id}>{user.name}</li>)}</ul>;
64
+ };
65
+ ```
66
+
67
+ ## 📚 Documentation
68
+
69
+ - [Getting Started](https://hyperfetch.bettertyped.com/docs/getting-started/quick-start)
70
+ - [React Overview](https://hyperfetch.bettertyped.com/docs/react/overview)
71
+ - [API Reference](https://hyperfetch.bettertyped.com/api/)
72
+
73
+ ## 💡 Examples
74
+
75
+ ### Fetch with callbacks
76
+
77
+ ```tsx
78
+ import { useFetch } from "@hyper-fetch/react";
79
+
80
+ const UserProfile = ({ userId }: { userId: number }) => {
81
+ // setParams makes the request dynamic — re-fetches when userId changes
82
+ const { data, loading, error, onSuccess, onError } = useFetch(
83
+ getUser.setParams({ userId }),
84
+ );
85
+
86
+ // Typed callbacks — response shape matches your request definition
87
+ onSuccess(({ response }) => {
88
+ console.log("Loaded user:", response.data.name);
89
+ });
90
+
91
+ onError(({ response }) => {
92
+ console.error("Failed to load user:", response.error);
93
+ });
94
+
95
+ if (loading) return <p>Loading...</p>;
96
+ if (error) return <p>Error: {error.message}</p>;
97
+ return <h1>{data.name}</h1>;
98
+ };
99
+ ```
100
+
101
+ ### Mutations with useSubmit
102
+
103
+ ```tsx
104
+ import { useSubmit } from "@hyper-fetch/react";
105
+
106
+ const CreateUserForm = () => {
107
+ // useSubmit doesn't fire on mount — it waits for you to call submit()
108
+ const { submit, submitting, onSubmitSuccess, onSubmitError } = useSubmit(createUser);
109
+
110
+ // Callbacks fire after each submission with typed response data
111
+ onSubmitSuccess(({ response }) => {
112
+ alert(`User ${response.data.name} created!`);
113
+ });
114
+
115
+ onSubmitError(({ response }) => {
116
+ alert(`Error: ${response.error.message}`);
117
+ });
118
+
119
+ const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
120
+ e.preventDefault();
121
+ const form = new FormData(e.currentTarget);
122
+ // Pass typed payload — TypeScript ensures the shape matches your request definition
123
+ submit({
124
+ data: { name: form.get("name") as string, email: form.get("email") as string },
125
+ });
126
+ };
127
+
128
+ return (
129
+ <form onSubmit={handleSubmit}>
130
+ <input name="name" placeholder="Name" required />
131
+ <input name="email" placeholder="Email" required />
132
+ <button type="submit" disabled={submitting}>
133
+ {submitting ? "Creating..." : "Create User"}
134
+ </button>
135
+ </form>
136
+ );
137
+ };
138
+ ```
139
+
140
+ ### Dependent requests
141
+
142
+ ```tsx
143
+ const UserPosts = ({ userId }: { userId: number }) => {
144
+ // First request fetches the user
145
+ const { data: user } = useFetch(getUser.setParams({ userId }));
146
+ // Second request waits until user is loaded — no useEffect chains needed
147
+ const { data: posts } = useFetch(getUserPosts.setParams({ userId }), {
148
+ disabled: !user,
149
+ });
150
+
151
+ return (
152
+ <div>
153
+ <h1>{user?.name}</h1>
154
+ {posts?.map((post) => <article key={post.id}>{post.title}</article>)}
155
+ </div>
156
+ );
157
+ };
158
+ ```
159
+
160
+ ### Optimistic updates with automatic rollback
161
+
162
+ ```tsx
163
+ import { useSubmit } from "@hyper-fetch/react";
164
+
165
+ const AddComment = ({ postId }: { postId: number }) => {
166
+ // setOptimistic runs BEFORE the request — update the list instantly
167
+ const optimisticAdd = addComment.setParams({ postId }).setOptimistic((request, client) => {
168
+ const cacheKey = getComments.setParams({ postId });
169
+ const previous = client.cache.get(cacheKey);
170
+
171
+ // Immediately insert the new comment into the cached list
172
+ const optimisticComment = { id: `temp-${Date.now()}`, text: request.data.text, author: "You" };
173
+ client.cache.set(cacheKey, {
174
+ ...previous,
175
+ data: [...(previous?.data || []), optimisticComment],
176
+ });
177
+
178
+ return {
179
+ context: { previous },
180
+ // If the request fails, put the old list back
181
+ rollback: () => client.cache.set(cacheKey, previous),
182
+ // On success, refetch to get the real server data
183
+ invalidate: [cacheKey],
184
+ };
185
+ });
186
+
187
+ const { submit, submitting, onSubmitError } = useSubmit(optimisticAdd);
188
+
189
+ // mutationContext is fully typed from your setOptimistic return
190
+ onSubmitError(({ mutationContext }) => {
191
+ console.log("Rolled back — restored", mutationContext?.previous?.data?.length, "comments");
192
+ });
193
+
194
+ const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
195
+ e.preventDefault();
196
+ const text = new FormData(e.currentTarget).get("text") as string;
197
+ submit({ data: { text } });
198
+ e.currentTarget.reset();
199
+ };
200
+
201
+ return (
202
+ <form onSubmit={handleSubmit}>
203
+ <input name="text" placeholder="Write a comment..." required />
204
+ <button type="submit" disabled={submitting}>Post</button>
205
+ </form>
206
+ );
207
+ };
208
+ ```
209
+
210
+ ## License
211
+
212
+ [MIT](https://github.com/BetterTyped/hyper-fetch/blob/main/License.md)
@@ -175,6 +175,21 @@ describe("useTrackedState [ Utils ]", () => {
175
175
  const result = getValidCacheData(mockRequest, null, cacheData);
176
176
  expect(result).toBe(cacheData);
177
177
  });
178
+
179
+ it("should return stale cache data for stale-while-revalidate", () => {
180
+ const staleTimestamp = new Date().getTime() - 5000; // Well beyond the 1000ms staleTime
181
+ const cacheData = {
182
+ data: "stale-data",
183
+ error: null,
184
+ status: 200,
185
+ success: true,
186
+ extra: null,
187
+ responseTimestamp: staleTimestamp,
188
+ } as any;
189
+
190
+ const result = getValidCacheData(mockRequest, null, cacheData);
191
+ expect(result).toBe(cacheData);
192
+ });
178
193
  });
179
194
 
180
195
  describe("when getInitialState handles async responseMapper", () => {
@@ -57,7 +57,7 @@ describe("useFetch [ Base ]", () => {
57
57
  const view = renderUseFetch(request);
58
58
  await testCacheState(cache, view);
59
59
  });
60
- it("should not load stale cache data", async () => {
60
+ it("should show stale cache data while revalidating", async () => {
61
61
  await testClientIsolation(client);
62
62
  const timestamp = +new Date() - 11;
63
63
  const mock = mockRequest(request, { delay: 50 });
@@ -85,9 +85,9 @@ describe("useFetch [ Base ]", () => {
85
85
 
86
86
  await testCacheState(
87
87
  {
88
- data: null,
88
+ data: mock,
89
89
  error: null,
90
- status: null,
90
+ status: 200,
91
91
  success: true,
92
92
  extra: xhrExtra,
93
93
  responseTimestamp: timestamp,
@@ -1 +1 @@
1
- {"version":3,"file":"use-tracked-state.utils.d.ts","sourceRoot":"","sources":["../../../src/helpers/use-tracked-state/use-tracked-state.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,UAAU,EACV,kBAAkB,EAElB,mBAAmB,EAGpB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAanD;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,MAAM,MAAM,GAAG,UAAU,GAAG,OAAO,EACnC,aAAa,MAAM,EACnB,aAAa,MAAM,KAClB,OAQF,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,QAAQ,mBAAmB,CAAC,eAAe,CAAC,EAC5C,UAAU,OAAO,CAAC,mBAAmB,CAAC,KACrC,mBAYF,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,WAAW,MAAM,EAAE,gBAAgB,YAAY,CAAC,IAAI,GAAG,MAAM,CAAC,YAG9F,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,eAAe,EACzD,SAAS,CAAC,EACV,iBAAiB,YAAY,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,EACrE,WAAW,YAAY,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,KAC1G,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,IA4BvF,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,YAAY,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,gBAEnE,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,eAAe,EAAE,2DAM9D;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,YASA,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,eAAe,EAAE,iEAMxD;IACD,eAAe,EAAE,YAAY,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,KAAG,mBAAmB,CAAC,CAAC,CAgDxB,CAAC"}
1
+ {"version":3,"file":"use-tracked-state.utils.d.ts","sourceRoot":"","sources":["../../../src/helpers/use-tracked-state/use-tracked-state.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,UAAU,EACV,kBAAkB,EAElB,mBAAmB,EAGpB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAanD;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,MAAM,MAAM,GAAG,UAAU,GAAG,OAAO,EACnC,aAAa,MAAM,EACnB,aAAa,MAAM,KAClB,OAQF,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,QAAQ,mBAAmB,CAAC,eAAe,CAAC,EAC5C,UAAU,OAAO,CAAC,mBAAmB,CAAC,KACrC,mBAYF,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,WAAW,MAAM,EAAE,gBAAgB,YAAY,CAAC,IAAI,GAAG,MAAM,CAAC,YAG9F,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,eAAe,EACzD,SAAS,CAAC,EACV,iBAAiB,YAAY,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,EACrE,WAAW,YAAY,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,KAC1G,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,IA0BvF,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,YAAY,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,gBAEnE,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,eAAe,EAAE,2DAM9D;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,YASA,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,eAAe,EAAE,iEAMxD;IACD,eAAe,EAAE,YAAY,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,KAAG,mBAAmB,CAAC,CAAC,CAgDxB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { ClientInstance } from '@hyper-fetch/core';
2
2
  import { UseAppManagerReturnType } from '.';
3
+ /** Track the application's online/offline and focus/blur state through the client's AppManager. */
3
4
  export declare const useAppManager: <Client extends ClientInstance>(client: Client) => UseAppManagerReturnType;
4
5
  //# sourceMappingURL=use-app-manager.hooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-app-manager.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-app-manager/use-app-manager.hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,cAAc,EAAE,QAAQ,MAAM,KAAG,uBA6B7E,CAAC"}
1
+ {"version":3,"file":"use-app-manager.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-app-manager/use-app-manager.hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,mGAAmG;AACnG,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,cAAc,EAAE,QAAQ,MAAM,KAAG,uBA6B7E,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { RequestInstance } from '@hyper-fetch/core';
2
2
  import { UseCacheOptionsType, UseCacheReturnType } from '.';
3
+ /** Subscribe to cache updates for a given request without triggering network activity. */
3
4
  export declare const useCache: <T extends RequestInstance>(request: T, options?: UseCacheOptionsType<T>) => UseCacheReturnType<T>;
4
5
  //# sourceMappingURL=use-cache.hooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-cache.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-cache/use-cache.hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAM/E,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,eAAe,EAChD,SAAS,CAAC,EACV,UAAU,mBAAmB,CAAC,CAAC,CAAC,KAC/B,kBAAkB,CAAC,CAAC,CA4FtB,CAAC"}
1
+ {"version":3,"file":"use-cache.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-cache/use-cache.hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAM/E,0FAA0F;AAC1F,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,eAAe,EAChD,SAAS,CAAC,EACV,UAAU,mBAAmB,CAAC,CAAC,CAAC,KAC/B,kBAAkB,CAAC,CAAC,CA4FtB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { EmitterInstance, EmitterCallbackErrorType, EmitType } from '@hyper-fetch/sockets';
2
2
  import { UseEmitterOptionsType } from '.';
3
+ /** Send messages through a socket emitter with tracked connection state and lifecycle callbacks. */
3
4
  export declare const useEmitter: <EmitterType extends EmitterInstance>(emitter: EmitterType, options?: UseEmitterOptionsType) => {
4
5
  onEmit: (callback: (emitter: EmitterType) => void) => void;
5
6
  onEmitError: (callback: EmitterCallbackErrorType) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"use-emitter.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-emitter/use-emitter.hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAK/D,eAAO,MAAM,UAAU,GAAI,WAAW,SAAS,eAAe,EAC5D,SAAS,WAAW,EACpB,UAAU,qBAAqB;uBA+CL,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI;4BAIzB,wBAAwB;;;;;;;;;;;;;;;;;;;;CAmBxD,CAAC"}
1
+ {"version":3,"file":"use-emitter.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-emitter/use-emitter.hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAK/D,oGAAoG;AACpG,eAAO,MAAM,UAAU,GAAI,WAAW,SAAS,eAAe,EAC5D,SAAS,WAAW,EACpB,UAAU,qBAAqB;uBA+CL,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI;4BAIzB,wBAAwB;;;;;;;;;;;;;;;;;;;;CAmBxD,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export type UseEmitterOptionsType = {
2
+ /** When true (default), only re-renders when accessed state properties change */
2
3
  dependencyTracking?: boolean;
3
4
  };
4
5
  //# sourceMappingURL=use-emitter.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-emitter.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-emitter/use-emitter.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC"}
1
+ {"version":3,"file":"use-emitter.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-emitter/use-emitter.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,iFAAiF;IACjF,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import { RequestInstance } from '@hyper-fetch/core';
2
2
  import { UseFetchOptionsType, UseFetchReturnType } from '.';
3
3
  /**
4
- * This hooks aims to retrieve data from server.
4
+ * This hook aims to retrieve data from the server. It automatically fetches on mount and
5
+ * refetches based on dependencies, with support for caching, polling, and suspense.
5
6
  * @param request Request instance
6
7
  * @param options Hook options
7
8
  * @returns
@@ -1 +1 @@
1
- {"version":3,"file":"use-fetch.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-fetch/use-fetch.hooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAS/E;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,eAAe,EAChD,SAAS,CAAC,EACV,UAAU,mBAAmB,CAAC,CAAC,CAAC,KAC/B,kBAAkB,CAAC,CAAC,CAmUtB,CAAC"}
1
+ {"version":3,"file":"use-fetch.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-fetch/use-fetch.hooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAS/E;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,eAAe,EAChD,SAAS,CAAC,EACV,UAAU,mBAAmB,CAAC,CAAC,CAAC,KAC/B,kBAAkB,CAAC,CAAC,CAmUtB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { ListenerInstance, ExtractListenerResponseType } from '@hyper-fetch/sockets';
2
2
  import { UseListenerOptionsType } from '.';
3
+ /** Subscribe to incoming socket messages on a given listener topic with tracked connection state and callbacks. */
3
4
  export declare const useListener: <ListenerType extends ListenerInstance>(listener: ListenerType, options?: UseListenerOptionsType) => {
4
5
  listen: () => void;
5
6
  onEvent: (callback: NonNullable<((response: {
@@ -1 +1 @@
1
- {"version":3,"file":"use-listener.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-listener/use-listener.hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAI1F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAIjE,eAAO,MAAM,WAAW,GAAI,YAAY,SAAS,gBAAgB,EAC/D,UAAU,YAAY,EACtB,UAAU,sBAAsB;;wBAkCV,WAAW,aAtBZ;QAAE,IAAI,EAAE,2BAA2B,CAAC,YAAY,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,KAAK,IAAI,SAsB5C;;;;;;;;;;;;;;;;;;;;;;CAsClE,CAAC"}
1
+ {"version":3,"file":"use-listener.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-listener/use-listener.hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAI1F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAIjE,mHAAmH;AACnH,eAAO,MAAM,WAAW,GAAI,YAAY,SAAS,gBAAgB,EAC/D,UAAU,YAAY,EACtB,UAAU,sBAAsB;;wBAkCV,WAAW,aAtBZ;QAAE,IAAI,EAAE,2BAA2B,CAAC,YAAY,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,KAAK,IAAI,SAsB5C;;;;;;;;;;;;;;;;;;;;;;CAsClE,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export type UseListenerOptionsType = {
2
+ /** When true (default), only re-renders when accessed state properties change */
2
3
  dependencyTracking?: boolean;
3
4
  };
4
5
  //# sourceMappingURL=use-listener.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-listener.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-listener/use-listener.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG;IACnC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC"}
1
+ {"version":3,"file":"use-listener.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-listener/use-listener.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG;IACnC,iFAAiF;IACjF,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import { RequestInstance } from '@hyper-fetch/core';
2
2
  import { UseQueueOptionsType, UseQueueReturnType } from '.';
3
3
  /**
4
- * This hook allows to control dispatchers request queues
4
+ * This hook allows you to monitor and control dispatcher request queues for a given request,
5
+ * including starting, stopping, pausing, and inspecting pending/in-flight items.
5
6
  * @param request
6
7
  * @param options
7
8
  * @returns
@@ -1 +1 @@
1
- {"version":3,"file":"use-queue.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-queue/use-queue.hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAuD,MAAM,mBAAmB,CAAC;AAI9G,OAAO,KAAK,EAAE,mBAAmB,EAAgB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAa7F;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,SAAS,eAAe,EACtD,SAAS,OAAO,EAChB,UAAU,mBAAmB,KAC5B,kBAAkB,CAAC,OAAO,CAyL5B,CAAC"}
1
+ {"version":3,"file":"use-queue.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-queue/use-queue.hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAuD,MAAM,mBAAmB,CAAC;AAI9G,OAAO,KAAK,EAAE,mBAAmB,EAAgB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAa7F;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,SAAS,eAAe,EACtD,SAAS,OAAO,EAChB,UAAU,mBAAmB,KAC5B,kBAAkB,CAAC,OAAO,CAyL5B,CAAC"}
@@ -1,12 +1,18 @@
1
1
  import { ProgressType, RequestInstance, ResolvedQueueItemType, Dispatcher, ExtractAdapterType } from '@hyper-fetch/core';
2
2
  export type UseQueueOptionsType = {
3
+ /** Which dispatcher to use: "auto" picks based on request method, "fetch" or "submit" forces a specific one */
3
4
  dispatcherType?: "auto" | "fetch" | "submit";
5
+ /** When true, completed requests remain in the queue list for inspection */
4
6
  keepFinishedRequests?: boolean;
5
7
  };
6
8
  export type QueueRequest<Request extends RequestInstance> = ResolvedQueueItemType<Request> & {
9
+ /** Whether the request has failed after all retry attempts */
7
10
  failed?: boolean;
11
+ /** Whether the request was canceled before completing */
8
12
  canceled?: boolean;
13
+ /** Whether the request was removed from the queue */
9
14
  removed?: boolean;
15
+ /** Whether the request completed successfully */
10
16
  success?: boolean;
11
17
  /**
12
18
  * Uploading progress for given request
@@ -1 +1 @@
1
- {"version":3,"file":"use-queue.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-queue/use-queue.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC7C,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,eAAe,IAAI,qBAAqB,CAAC,OAAO,CAAC,GAAG;IAC3F,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,YAAY,CAAC;IACxB;;OAEG;IACH,WAAW,EAAE,YAAY,CAAC;IAC1B;;OAEG;IACH,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB;;OAEG;IACH,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,eAAe,IAAI;IAC1D;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C;;OAEG;IACH,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC"}
1
+ {"version":3,"file":"use-queue.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-queue/use-queue.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,mBAAmB,GAAG;IAChC,+GAA+G;IAC/G,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC7C,4EAA4E;IAC5E,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,eAAe,IAAI,qBAAqB,CAAC,OAAO,CAAC,GAAG;IAC3F,8DAA8D;IAC9D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qDAAqD;IACrD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iDAAiD;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,YAAY,CAAC;IACxB;;OAEG;IACH,WAAW,EAAE,YAAY,CAAC;IAC1B;;OAEG;IACH,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB;;OAEG;IACH,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,eAAe,IAAI;IAC1D;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C;;OAEG;IACH,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import { RequestInstance } from '@hyper-fetch/core';
2
2
  import { UseSubmitOptionsType, UseSubmitReturnType } from '.';
3
3
  /**
4
- * This hooks aims to mutate data on the server.
4
+ * This hook aims to mutate data on the server. Unlike useFetch, it does not fire automatically -
5
+ * call the returned `submit` function to trigger the request (e.g., on button click).
5
6
  * @param request
6
7
  * @param options
7
8
  * @returns
@@ -1 +1 @@
1
- {"version":3,"file":"use-submit.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-submit/use-submit.hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAOhB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAOlF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,SAAS,eAAe,EAC3D,SAAS,WAAW,EACpB,UAAU,oBAAoB,CAAC,WAAW,CAAC,KAC1C,mBAAmB,CAAC,WAAW,CAiNjC,CAAC"}
1
+ {"version":3,"file":"use-submit.hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-submit/use-submit.hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAOhB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAOlF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,SAAS,eAAe,EAC3D,SAAS,WAAW,EACpB,UAAU,oBAAoB,CAAC,WAAW,CAAC,KAC1C,mBAAmB,CAAC,WAAW,CAiNjC,CAAC"}
package/dist/index.mjs CHANGED
@@ -478,7 +478,7 @@ var isStaleCacheData = (staleTime, staleTimestamp) => {
478
478
  return +/* @__PURE__ */ new Date() > +staleTimestamp + staleTime;
479
479
  };
480
480
  var getValidCacheData = (request, initialResponse, cacheData) => {
481
- if (!isStaleCacheData(request.staleTime, cacheData?.responseTimestamp) && cacheData) return cacheData;
481
+ if (cacheData) return cacheData;
482
482
  if (initialResponse) return {
483
483
  data: null,
484
484
  error: null,
@@ -936,7 +936,8 @@ var useProvider = () => {
936
936
  var suspensePromiseMap = /* @__PURE__ */ new Map();
937
937
  var suspenseResultMap = /* @__PURE__ */ new Map();
938
938
  /**
939
- * This hooks aims to retrieve data from server.
939
+ * This hook aims to retrieve data from the server. It automatically fetches on mount and
940
+ * refetches based on dependencies, with support for caching, polling, and suspense.
940
941
  * @param request Request instance
941
942
  * @param options Hook options
942
943
  * @returns
@@ -1232,7 +1233,8 @@ var useFetchDefaultOptions = {
1232
1233
  //#endregion
1233
1234
  //#region src/hooks/use-submit/use-submit.hooks.ts
1234
1235
  /**
1235
- * This hooks aims to mutate data on the server.
1236
+ * This hook aims to mutate data on the server. Unlike useFetch, it does not fire automatically -
1237
+ * call the returned `submit` function to trigger the request (e.g., on button click).
1236
1238
  * @param request
1237
1239
  * @param options
1238
1240
  * @returns
@@ -1409,7 +1411,8 @@ var canUpdate = (item) => {
1409
1411
  return true;
1410
1412
  };
1411
1413
  /**
1412
- * This hook allows to control dispatchers request queues
1414
+ * This hook allows you to monitor and control dispatcher request queues for a given request,
1415
+ * including starting, stopping, pausing, and inspecting pending/in-flight items.
1413
1416
  * @param request
1414
1417
  * @param options
1415
1418
  * @returns
@@ -1579,6 +1582,7 @@ var useQueueDefaultOptions = {
1579
1582
  };
1580
1583
  //#endregion
1581
1584
  //#region src/hooks/use-cache/use-cache.hooks.ts
1585
+ /** Subscribe to cache updates for a given request without triggering network activity. */
1582
1586
  var useCache = (request, options) => {
1583
1587
  const { cacheKey, client } = request;
1584
1588
  const { cache, loggerManager } = client;
@@ -1778,6 +1782,7 @@ var useStream = (request, options) => {
1778
1782
  };
1779
1783
  //#endregion
1780
1784
  //#region src/hooks/use-listener/use-listener.hooks.ts
1785
+ /** Subscribe to incoming socket messages on a given listener topic with tracked connection state and callbacks. */
1781
1786
  var useListener = (listener, options) => {
1782
1787
  const { config: globalConfig } = useProvider();
1783
1788
  const { dependencyTracking } = {
@@ -1841,6 +1846,7 @@ var useListener = (listener, options) => {
1841
1846
  };
1842
1847
  //#endregion
1843
1848
  //#region src/hooks/use-emitter/use-emitter.hooks.ts
1849
+ /** Send messages through a socket emitter with tracked connection state and lifecycle callbacks. */
1844
1850
  var useEmitter = (emitter, options) => {
1845
1851
  const { config: globalConfig } = useProvider();
1846
1852
  const { dependencyTracking } = {
@@ -1900,6 +1906,7 @@ var useEmitter = (emitter, options) => {
1900
1906
  };
1901
1907
  //#endregion
1902
1908
  //#region src/hooks/use-app-manager/use-app-manager.hooks.ts
1909
+ /** Track the application's online/offline and focus/blur state through the client's AppManager. */
1903
1910
  var useAppManager = (client) => {
1904
1911
  const [online, setIsOnline] = useState(client.appManager.isOnline);
1905
1912
  const [focused, setIsFocused] = useState(client.appManager.isFocused);