@data-client/vue 0.18.0 โ 0.18.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.
- package/CHANGELOG.md +381 -1
- package/README.md +86 -41
- package/dist/index.js +223 -158
- package/dist/index.umd.min.js +1 -1
- package/lib/consumers/refetchTriggers.d.ts +12 -0
- package/lib/consumers/refetchTriggers.d.ts.map +1 -0
- package/lib/consumers/refetchTriggers.js +9 -0
- package/lib/consumers/useCache.d.ts +1 -1
- package/lib/consumers/useCache.d.ts.map +1 -1
- package/lib/consumers/useCache.js +3 -53
- package/lib/consumers/useCacheResponse.d.ts +20 -0
- package/lib/consumers/useCacheResponse.d.ts.map +1 -0
- package/lib/consumers/useCacheResponse.js +55 -0
- package/lib/consumers/useCountRef.d.ts +7 -0
- package/lib/consumers/useCountRef.d.ts.map +1 -0
- package/lib/consumers/useCountRef.js +10 -0
- package/lib/consumers/useDLE.d.ts +1 -1
- package/lib/consumers/useDLE.d.ts.map +1 -1
- package/lib/consumers/useDLE.js +16 -62
- package/lib/consumers/useDebounce.d.ts +1 -1
- package/lib/consumers/useDebounce.d.ts.map +1 -1
- package/lib/consumers/useDebounce.js +1 -2
- package/lib/consumers/useExpired.d.ts +12 -0
- package/lib/consumers/useExpired.d.ts.map +1 -0
- package/lib/consumers/useExpired.js +19 -0
- package/lib/consumers/useFetch.d.ts +8 -11
- package/lib/consumers/useFetch.d.ts.map +1 -1
- package/lib/consumers/useFetch.js +13 -24
- package/lib/consumers/useLive.js +1 -1
- package/lib/consumers/useLoading.d.ts +1 -1
- package/lib/consumers/useLoading.d.ts.map +1 -1
- package/lib/consumers/useLoading.js +1 -2
- package/lib/consumers/useQuery.d.ts +1 -1
- package/lib/consumers/useQuery.d.ts.map +1 -1
- package/lib/consumers/useQuery.js +6 -12
- package/lib/consumers/useResponseMeta.d.ts +23 -0
- package/lib/consumers/useResponseMeta.d.ts.map +1 -0
- package/lib/consumers/useResponseMeta.js +36 -0
- package/lib/consumers/useSubscription.js +4 -4
- package/lib/consumers/useSuspense.d.ts +1 -1
- package/lib/consumers/useSuspense.d.ts.map +1 -1
- package/lib/consumers/useSuspense.js +58 -34
- package/lib/context.d.ts +1 -1
- package/lib/context.d.ts.map +1 -1
- package/lib/context.js +3 -3
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -2
- package/lib/internal.d.ts +6 -0
- package/lib/internal.d.ts.map +1 -0
- package/lib/internal.js +6 -0
- package/lib/providers/DataClientPlugin.d.ts +1 -1
- package/lib/providers/DataClientPlugin.d.ts.map +1 -1
- package/lib/providers/DataClientPlugin.js +16 -4
- package/lib/providers/createDataClient.d.ts +10 -4
- package/lib/providers/createDataClient.d.ts.map +1 -1
- package/lib/providers/createDataClient.js +11 -5
- package/lib/providers/getDefaultManagers.d.ts.map +1 -1
- package/lib/providers/getDefaultManagers.js +1 -1
- package/lib/providers/index.d.ts +2 -1
- package/lib/providers/index.d.ts.map +1 -1
- package/lib/providers/index.js +1 -1
- package/lib/test/MockPlugin.d.ts +1 -1
- package/lib/test/MockPlugin.d.ts.map +1 -1
- package/lib/test/MockPlugin.js +1 -1
- package/lib/test/index.d.ts +2 -1
- package/lib/test/index.d.ts.map +1 -1
- package/lib/test/index.js +1 -1
- package/lib/test/mountDataClient.d.ts +5 -3
- package/lib/test/mountDataClient.d.ts.map +1 -1
- package/lib/test/mountDataClient.js +15 -10
- package/lib/test/renderDataCompose.d.ts +10 -4
- package/lib/test/renderDataCompose.d.ts.map +1 -1
- package/lib/test/renderDataCompose.js +2 -3
- package/package.json +21 -6
- package/src/__tests__/__snapshots__/context.test.ts.snap +2 -2
- package/src/__tests__/context.test.ts +1 -1
- package/src/__tests__/integration-garbage-collection.web.ts +80 -4
- package/src/__tests__/useCache.web.ts +160 -93
- package/src/__tests__/useDLE.web.ts +204 -96
- package/src/__tests__/useFetch.web.ts +100 -37
- package/src/__tests__/useQuery.web.ts +60 -50
- package/src/__tests__/useSubscription.web.ts +74 -75
- package/src/__tests__/useSuspense.web.ts +455 -46
- package/src/consumers/refetchTriggers.ts +22 -0
- package/src/consumers/useCache.ts +7 -70
- package/src/consumers/useCacheResponse.ts +56 -0
- package/src/consumers/useCountRef.ts +15 -0
- package/src/consumers/useDLE.ts +24 -83
- package/src/consumers/useDebounce.ts +2 -1
- package/src/consumers/useExpired.ts +26 -0
- package/src/consumers/useFetch.ts +34 -49
- package/src/consumers/useLive.ts +1 -1
- package/src/consumers/useLoading.ts +2 -1
- package/src/consumers/useQuery.ts +10 -13
- package/src/consumers/useResponseMeta.ts +41 -0
- package/src/consumers/useSubscription.ts +3 -3
- package/src/consumers/useSuspense.ts +66 -58
- package/src/context.ts +4 -3
- package/src/index.ts +7 -1
- package/src/internal.ts +12 -0
- package/src/providers/DataClientPlugin.ts +17 -3
- package/src/providers/__tests__/DataClientPlugin.test.ts +40 -1
- package/src/providers/createDataClient.ts +15 -5
- package/src/providers/getDefaultManagers.ts +2 -6
- package/src/providers/index.ts +2 -5
- package/src/test/MockPlugin.ts +3 -3
- package/src/test/README.md +10 -304
- package/src/test/__tests__/mountDataClient.test.ts +38 -0
- package/src/test/index.ts +2 -1
- package/src/test/mountDataClient.ts +22 -17
- package/src/test/renderDataCompose.ts +11 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,385 @@
|
|
|
1
1
|
# @data-client/vue
|
|
2
2
|
|
|
3
|
+
## 0.18.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4230](https://github.com/reactive/data-client/pull/4230) [`46f1f24`](https://github.com/reactive/data-client/commit/46f1f24bcb04824805747ed2a1effe7baece337c) - Fix `controller.set()` types for a single [Invalidate](https://dataclient.io/rest/api/Invalidate)
|
|
8
|
+
|
|
9
|
+
Deleting one entity with `set()` worked at runtime but failed to typecheck, since `Invalidate` isn't
|
|
10
|
+
[Queryable](https://dataclient.io/rest/api/schema#queryable). Pass the schema and the row to delete; the row is typed
|
|
11
|
+
by the Entity's fields.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// Before: TypeScript error
|
|
15
|
+
// After: no error
|
|
16
|
+
ctrl.set(new Invalidate(Post), { id: '5' });
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
It takes no `args` and no updater function.
|
|
20
|
+
|
|
21
|
+
- [#4133](https://github.com/reactive/data-client/pull/4133) [`a82758c`](https://github.com/reactive/data-client/commit/a82758cd1998e58d7ad280407db28bd84f5d7b18) - Fix `controller.set()` accepting any value
|
|
22
|
+
|
|
23
|
+
Values are now typed by the schema: Entities take their fields, while [Collection](https://dataclient.io/rest/api/Collection)
|
|
24
|
+
and [All](https://dataclient.io/rest/api/All) take a list of rows. [Query](https://dataclient.io/rest/api/Query) takes
|
|
25
|
+
the input of the schema it wraps, not what its `process()` returns. Updater functions must return the same.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
// Before: these all typechecked, then failed or wrote nothing at runtime
|
|
29
|
+
ctrl.set(new schema.All(Todo), 42);
|
|
30
|
+
ctrl.set(TodoResource.getList.schema, 'anything');
|
|
31
|
+
ctrl.set(Todo, { id: '5' }, { id: '5', completed: 'yes' });
|
|
32
|
+
|
|
33
|
+
// After: TypeScript errors on the above; these typecheck
|
|
34
|
+
ctrl.set(TodoResource.getList.schema, [{ id: '5', completed: true }]);
|
|
35
|
+
ctrl.set(new schema.All(Todo), [{ id: '5', completed: true }]);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
When each member declares its discriminator as a literal (like `readonly type = 'post'`), a
|
|
39
|
+
[Union](https://dataclient.io/rest/api/Union) row is checked against the member it selects. Only
|
|
40
|
+
declared fields are accepted, so a key read by a `schemaAttribute` function must be declared on each member.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
const Feed = new schema.Union({ post: Post, comment: Comment }, 'type');
|
|
44
|
+
// TypeScript error: commentBody is a Comment field, not a Post field
|
|
45
|
+
ctrl.set(
|
|
46
|
+
Feed,
|
|
47
|
+
{ id: '1', type: 'post' },
|
|
48
|
+
{ type: 'post', commentBody: 'hi' },
|
|
49
|
+
);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
- [#4228](https://github.com/reactive/data-client/pull/4228) [`b55696c`](https://github.com/reactive/data-client/commit/b55696c72ad3e73e0a2f50d3751c7104cd4ad9ee) - Fix TypeScript error passing a `Controller` subclass to `DataProvider` or `DataClientPlugin`
|
|
53
|
+
|
|
54
|
+
A plain `class MyController extends Controller` failed to typecheck as the `Controller` option of [DataProvider](https://dataclient.io/docs/api/DataProvider#Controller), Vue's [DataClientPlugin](https://dataclient.io/vue/api/DataClientPlugin#Controller), and the `@data-client/react/redux` `DataProvider`, so the documented example needed a cast. `MockController()` from `@data-client/core/mock` had the same error when wrapping your subclass. These now typecheck, and you can drop the casts.
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
class MyController extends Controller {
|
|
58
|
+
doSomething = () => console.log('hi');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Before: TypeScript error, so you had to cast
|
|
62
|
+
<DataProvider Controller={MyController as typeof Controller}>
|
|
63
|
+
app.use(DataClientPlugin, { Controller: MyController as typeof Controller });
|
|
64
|
+
|
|
65
|
+
// After
|
|
66
|
+
<DataProvider Controller={MyController}>
|
|
67
|
+
app.use(DataClientPlugin, { Controller: MyController });
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- [#4150](https://github.com/reactive/data-client/pull/4150) [`74e67fa`](https://github.com/reactive/data-client/commit/74e67fa2c4f9f104f5b7a49e877a48e5963e4bd2) - Fix `useCache()` and `useDLE()` returning a truthy `Symbol` for deleted entities
|
|
71
|
+
|
|
72
|
+
After an entity was deleted and its refetch failed, `useCache()` and `useDLE()` (React and Vue) returned an internal
|
|
73
|
+
`Symbol` instead of `undefined`. Since a `Symbol` is truthy, "not loaded" checks passed, and code went on to use it as
|
|
74
|
+
the entity:
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
const todo = useCache(TodoResource.get, { id });
|
|
78
|
+
if (!todo) return <TodoPlaceholder />;
|
|
79
|
+
// Before: reached here with a Symbol; todo.title was undefined and todo.title.trim() threw
|
|
80
|
+
// After: the placeholder renders
|
|
81
|
+
return <TodoItem title={todo.title.trim()} />;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
[Controller.getResponse()](https://dataclient.io/docs/api/Controller#getResponse) and
|
|
85
|
+
[Controller.fetchIfStale()](https://dataclient.io/docs/api/Controller#fetchIfStale) now also give `undefined` there,
|
|
86
|
+
like [Controller.get()](https://dataclient.io/docs/api/Controller#get) already did.
|
|
87
|
+
|
|
88
|
+
- [#4163](https://github.com/reactive/data-client/pull/4163) [`159c963`](https://github.com/reactive/data-client/commit/159c9633679d95427fe4f626aec341c76e4578f8) - Fix slow updates in development while Redux DevTools is open
|
|
89
|
+
|
|
90
|
+
With the [Redux DevTools](https://dataclient.io/docs/getting-started/debugging) extension open, every store update
|
|
91
|
+
stalled the page while DevTools serialized the store: about 20ms with 50 entities, and 200ms with 500. Apps doing
|
|
92
|
+
many `controller.set()` calls, polling, or live updates would stutter in development. Each update now serializes
|
|
93
|
+
40-60x faster, and timestamps still show as readable times like `10:42:07.123 AM`.
|
|
94
|
+
|
|
95
|
+
- [#4227](https://github.com/reactive/data-client/pull/4227) [`47502c6`](https://github.com/reactive/data-client/commit/47502c664df913297fba3e5011a975dfd01c0d8d) - Type FETCH `action.meta.promise` as `Promise`
|
|
96
|
+
|
|
97
|
+
Managers can now call `.finally()` and `.catch()` on a FETCH action's `meta.promise` without a TypeScript error. It was always a real `Promise` at runtime, but was typed `PromiseLike`, which only has `.then()`.
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
// Before: TypeScript error on .finally(), so both callbacks went to .then()
|
|
101
|
+
const track = () =>
|
|
102
|
+
trackTiming(action.endpoint.name, performance.now() - start);
|
|
103
|
+
action.meta.promise.then(track, track);
|
|
104
|
+
|
|
105
|
+
// After
|
|
106
|
+
action.meta.promise
|
|
107
|
+
.finally(() => {
|
|
108
|
+
trackTiming(action.endpoint.name, performance.now() - start);
|
|
109
|
+
})
|
|
110
|
+
// the fetch's caller handles errors; this only observes timing
|
|
111
|
+
.catch(() => {});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
- [#4250](https://github.com/reactive/data-client/pull/4250) [`fc4b015`](https://github.com/reactive/data-client/commit/fc4b015ca0899a2685af881d17f765dce27ffc1a) - Fixture `args` accept readonly tuples
|
|
115
|
+
|
|
116
|
+
Fixtures written with `args: [...] as const` now type-check when passed to [MockResolver](https://dataclient.io/docs/api/MockResolver), `renderDataHook()`, Vue's `renderDataCompose()` or `mockInitialState()`. Before, TypeScript rejected them with "The type 'readonly [...]' is 'readonly' and cannot be assigned to the mutable type", so you had to drop `as const` or cast.
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
const fixtures = [
|
|
120
|
+
{
|
|
121
|
+
endpoint: TodoResource.getList,
|
|
122
|
+
args: [{ userId: 1 }] as const,
|
|
123
|
+
response: [{ id: 1, title: 'Write tests', userId: 1 }],
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
// Before: type error on `fixtures`. After: works as written
|
|
128
|
+
<MockResolver fixtures={fixtures}>
|
|
129
|
+
<TodoList />
|
|
130
|
+
</MockResolver>;
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- [#4232](https://github.com/reactive/data-client/pull/4232) [`31b1820`](https://github.com/reactive/data-client/commit/31b182033106d5ce44352481577d3c321e39ebe9) - Fix `',' expected` errors on TypeScript 4.0 through 4.4
|
|
134
|
+
|
|
135
|
+
Importing `@data-client/react/redux`, `@data-client/react/nextjs` or `@data-client/test` failed to compile on TypeScript before 4.5, even with `skipLibCheck` on, because their declaration files used syntax those versions can't parse. They now compile on TypeScript 4.0 and later.
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import { DataProvider } from '@data-client/react/nextjs';
|
|
139
|
+
import { renderDataHook } from '@data-client/test';
|
|
140
|
+
|
|
141
|
+
// Before (TypeScript 4.0 to 4.4):
|
|
142
|
+
// node_modules/@data-client/react/lib/server/nextjs/DataProvider/DataProvider.d.ts(1,15): error TS1005: ',' expected.
|
|
143
|
+
// node_modules/@data-client/test/lib/makeRenderDataClient/index.d.ts(3,33): error TS1005: ',' expected.
|
|
144
|
+
// After: no errors
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
`@data-client/vue/test` types now also resolve with `moduleResolution: "node"`.
|
|
148
|
+
|
|
149
|
+
- [#4122](https://github.com/reactive/data-client/pull/4122) [`b4b502d`](https://github.com/reactive/data-client/commit/b4b502d545aab0cf75bf030f3de4607a2e3ab7dc) - Fix types for TypeScript 4.x when `skipLibCheck` is off
|
|
150
|
+
|
|
151
|
+
TypeScript 4.0 through 4.7 no longer report `Cannot find name 'NoInfer'` from `@data-client/endpoint` or `@data-client/normalizr`, and TypeScript 4.0 through 4.9 no longer report `Only named exports may use 'export type'` from `@data-client/normalizr`.
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { Entity } from '@data-client/endpoint';
|
|
155
|
+
import { normalize } from '@data-client/normalizr';
|
|
156
|
+
|
|
157
|
+
// Before (TypeScript 4.7, skipLibCheck: false):
|
|
158
|
+
// error TS2304: Cannot find name 'NoInfer'.
|
|
159
|
+
// error TS1383: Only named exports may use 'export type'.
|
|
160
|
+
// After: no errors
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
- [#4019](https://github.com/reactive/data-client/pull/4019) [`aa15f29`](https://github.com/reactive/data-client/commit/aa15f29f6b0a3b4ae655e2d114a419a3fc94ac7e) Thanks [@renovate](https://github.com/apps/renovate)! - Fix TypeScript 7 module resolution for package exports
|
|
164
|
+
|
|
165
|
+
TypeScript 7 requires a `types` condition in `package.json` `exports`. Without it, imports resolved to runtime entrypoints like `node.mjs` and lost declaration files.
|
|
166
|
+
|
|
167
|
+
- [#4193](https://github.com/reactive/data-client/pull/4193) [`3e45adc`](https://github.com/reactive/data-client/commit/3e45adc831ead1923f0590d8b6ee316655610d69) - `createDataClient()` and `ProvidedDataClient` are deprecated
|
|
168
|
+
|
|
169
|
+
They only exist to implement [DataClientPlugin](https://dataclient.io/vue/api/DataClientPlugin) and will stop being
|
|
170
|
+
exported in a future release. Nothing changes at runtime. If you call `createDataClient()` directly, install the
|
|
171
|
+
plugin instead and read the controller with [useController()](https://dataclient.io/vue/api/useController).
|
|
172
|
+
|
|
173
|
+
```ts title="main.ts"
|
|
174
|
+
import { DataClientPlugin } from '@data-client/vue';
|
|
175
|
+
|
|
176
|
+
app.use(DataClientPlugin, { managers, initialState });
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
- [#4148](https://github.com/reactive/data-client/pull/4148) [`c5e95d4`](https://github.com/reactive/data-client/commit/c5e95d46a8d68ef04ccbcdc7bf90f663357a8530) - `DataClientPlugin` garbage collects by default
|
|
180
|
+
|
|
181
|
+
Previously, unused data was only removed from the store if you passed a `gcPolicy` yourself. It now defaults
|
|
182
|
+
to `new GCPolicy()`, matching `DataProvider` in `@data-client/react`, so you can drop the option unless you
|
|
183
|
+
customize it.
|
|
184
|
+
|
|
185
|
+
Before
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
import { DataClientPlugin, GCPolicy } from '@data-client/vue';
|
|
189
|
+
|
|
190
|
+
app.use(DataClientPlugin, { gcPolicy: new GCPolicy() });
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
After
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import { DataClientPlugin } from '@data-client/vue';
|
|
197
|
+
|
|
198
|
+
app.use(DataClientPlugin);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
- [#4221](https://github.com/reactive/data-client/pull/4221) [`76a50c8`](https://github.com/reactive/data-client/commit/76a50c853d863140122cecbeb141fb278853849d) - `waitForNextUpdate()` from `renderDataCompose()` is deprecated
|
|
202
|
+
|
|
203
|
+
It gives up silently after 1 second, so a test could pass while the composable was still suspended. When the Promise
|
|
204
|
+
had already resolved, it waited the full second for nothing, and under `jest.useFakeTimers()` it could hang. Await the
|
|
205
|
+
result directly instead, and use `allSettled()` after changing props or calling the controller.
|
|
206
|
+
|
|
207
|
+
`allSettled()` from `renderDataCompose()` and `mountDataClient()` now also waits for fetches that a prop change starts,
|
|
208
|
+
and for the component to re-render, so you no longer need `nextTick()` around it. It also waits on a `NetworkManager`
|
|
209
|
+
you pass in `managers`, instead of returning right away.
|
|
210
|
+
|
|
211
|
+
#### Before
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
import { reactive } from 'vue';
|
|
215
|
+
|
|
216
|
+
const props = reactive({ id: 5 });
|
|
217
|
+
const { result, waitForNextUpdate } = await renderDataCompose(
|
|
218
|
+
(props: { id: number }) =>
|
|
219
|
+
useSuspense(ArticleResource.get, () => ({ id: props.id })),
|
|
220
|
+
{ props, resolverFixtures },
|
|
221
|
+
);
|
|
222
|
+
await waitForNextUpdate();
|
|
223
|
+
const article = await result;
|
|
224
|
+
|
|
225
|
+
props.id = 6;
|
|
226
|
+
await waitForNextUpdate();
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### After
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
import { reactive } from 'vue';
|
|
233
|
+
|
|
234
|
+
const props = reactive({ id: 5 });
|
|
235
|
+
const { result, allSettled } = await renderDataCompose(
|
|
236
|
+
(props: { id: number }) =>
|
|
237
|
+
useSuspense(ArticleResource.get, () => ({ id: props.id })),
|
|
238
|
+
{ props, resolverFixtures },
|
|
239
|
+
);
|
|
240
|
+
const article = await result;
|
|
241
|
+
|
|
242
|
+
props.id = 6;
|
|
243
|
+
await allSettled();
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
- [#4142](https://github.com/reactive/data-client/pull/4142) [`f5cc51b`](https://github.com/reactive/data-client/commit/f5cc51b2f77230f64ab24d91eca0072521a24ded) - Fix `useDLE()` and `useCache()` dropping expired `invalidIfStale` data on unrelated store updates
|
|
247
|
+
|
|
248
|
+
After an `invalidIfStale` response expired, any unrelated store update switched these composables to empty data, and
|
|
249
|
+
`useDLE()` stayed `loading` without starting a fetch. Expiry is now only re-checked when the response's expiry, the
|
|
250
|
+
arguments, or a reset changes, matching `@data-client/react`.
|
|
251
|
+
|
|
252
|
+
The `vue` peer dependency is now `^3.4.0`.
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
const { data, loading } = useDLE(ArticleResource.get, { id: 5 });
|
|
256
|
+
// ...after the response's dataExpiryLength passes
|
|
257
|
+
await ctrl.setResponse(UserResource.get, { id: 1 }, user);
|
|
258
|
+
// Before: loading.value === true, data.value === undefined, and no fetch starts
|
|
259
|
+
// After: loading.value === false, data.value is still the article
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
- [#4143](https://github.com/reactive/data-client/pull/4143) [`743d8e3`](https://github.com/reactive/data-client/commit/743d8e3dcc5e69a0725616a3ffe2568dee5727e9) - Export `GCPolicy` from `@data-client/vue`
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
// Before
|
|
266
|
+
import { GCPolicy } from '@data-client/core';
|
|
267
|
+
// After
|
|
268
|
+
import { GCPolicy } from '@data-client/vue';
|
|
269
|
+
|
|
270
|
+
app.use(DataClientPlugin, {
|
|
271
|
+
gcPolicy: new GCPolicy({ intervalMS: 60 * 1000 * 10 }),
|
|
272
|
+
});
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
- [#4115](https://github.com/reactive/data-client/pull/4115) [`e350950`](https://github.com/reactive/data-client/commit/e35095045ade70f8151202b357beef2a38ff8272) - Fix getter function arguments in Vue composables
|
|
276
|
+
|
|
277
|
+
`useSuspense`, `useLive`, `useCache`, `useDLE`, `useFetch`, `useQuery` and `useSubscription`
|
|
278
|
+
were typed to accept getter functions as arguments, but only resolved refs at runtime. Getters
|
|
279
|
+
now work and are tracked reactively, just like refs and `computed`.
|
|
280
|
+
|
|
281
|
+
```ts
|
|
282
|
+
const props = defineProps<{ id: number }>();
|
|
283
|
+
|
|
284
|
+
// Before: getter was passed to the endpoint as-is
|
|
285
|
+
// After: re-fetches when props.id changes
|
|
286
|
+
const article = await useSuspense(ArticleResource.get, () => ({
|
|
287
|
+
id: props.id,
|
|
288
|
+
}));
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
- [#4270](https://github.com/reactive/data-client/pull/4270) [`1d693c6`](https://github.com/reactive/data-client/commit/1d693c6e26aa3774636844e5731c78ec9eabe86b) - Add `__INTERNAL__` export matching `@data-client/react`'s
|
|
292
|
+
|
|
293
|
+
Tooling built on `@data-client/vue` can now use `createReducer`, `initialState` and friends without adding `@data-client/core` as a direct dependency.
|
|
294
|
+
|
|
295
|
+
- [#4146](https://github.com/reactive/data-client/pull/4146) [`a8da8c7`](https://github.com/reactive/data-client/commit/a8da8c725de0097aff8fa9bab2f0db8ccfe7047c) - Fix `app.use(DataClientPlugin)` throwing `app.onUnmount is not a function` on Vue versions before 3.5
|
|
296
|
+
|
|
297
|
+
```ts
|
|
298
|
+
const app = createApp(App);
|
|
299
|
+
// Before (Vue < 3.5): TypeError: app.onUnmount is not a function
|
|
300
|
+
// After: installs, and stops the DataClient when the app unmounts
|
|
301
|
+
app.use(DataClientPlugin);
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
- [#4134](https://github.com/reactive/data-client/pull/4134) [`bd419cd`](https://github.com/reactive/data-client/commit/bd419cde7897f240440475adf942c64e6418307c) - Fix `useSuspense()`, `useDLE()` and `useFetch()` refetching stale data on every store update
|
|
305
|
+
|
|
306
|
+
Once data was stale, any store update (such as `controller.set()`) made these composables refetch, so the server
|
|
307
|
+
response could overwrite the change. They now only refetch when the data's expiry, the arguments, or a reset changes,
|
|
308
|
+
matching `@data-client/react`.
|
|
309
|
+
|
|
310
|
+
```ts
|
|
311
|
+
const article = await useSuspense(ArticleResource.get, { id: 5 });
|
|
312
|
+
// ...after the response's dataExpiryLength passes
|
|
313
|
+
await ctrl.set(Article, { id: 5 }, { id: 5, title: 'edited' });
|
|
314
|
+
// Before: triggers a refetch that reverts title to the server value
|
|
315
|
+
// After: title stays 'edited'
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
- [#4135](https://github.com/reactive/data-client/pull/4135) [`f03332e`](https://github.com/reactive/data-client/commit/f03332ea9a4e3b24dc1554cb3a4ff2ebc1b117ad) - Fix `useSuspense()` and `useLive()` fetch errors after arguments change being unhandled
|
|
319
|
+
|
|
320
|
+
When ref or computed arguments changed and the new fetch failed, the error became an unhandled promise rejection
|
|
321
|
+
and the result became `undefined`. Reading the result now throws the error, like the first load does, so it reaches
|
|
322
|
+
`onErrorCaptured()`.
|
|
323
|
+
|
|
324
|
+
```ts
|
|
325
|
+
const props = defineProps<{ id: number }>();
|
|
326
|
+
const todo = await useSuspense(
|
|
327
|
+
TodoResource.get,
|
|
328
|
+
computed(() => ({ id: props.id })),
|
|
329
|
+
);
|
|
330
|
+
// Before: a failed fetch for a new id was an unhandled rejection; todo.value became undefined
|
|
331
|
+
// After: reading todo.value throws the fetch error, caught by onErrorCaptured()
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
- [#4131](https://github.com/reactive/data-client/pull/4131) [`84b6766`](https://github.com/reactive/data-client/commit/84b67665f547bd52e7dc207af9ba768821041fac) - Fix `useSuspense()` and `useLive()` returning `undefined` while new arguments load
|
|
335
|
+
|
|
336
|
+
When ref or computed arguments changed to data not yet in the store, the result became `undefined` until the
|
|
337
|
+
new fetch resolved, crashing templates like `{{ todo.title }}`. It now keeps the previous data until the new data arrives.
|
|
338
|
+
|
|
339
|
+
```ts
|
|
340
|
+
const props = defineProps<{ id: number }>();
|
|
341
|
+
const todo = await useSuspense(
|
|
342
|
+
TodoResource.get,
|
|
343
|
+
computed(() => ({ id: props.id })),
|
|
344
|
+
);
|
|
345
|
+
// Before: todo.value was undefined while the new id loaded
|
|
346
|
+
// After: todo.value keeps the previous todo until the new one arrives
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
- [#4169](https://github.com/reactive/data-client/pull/4169) [`341e17c`](https://github.com/reactive/data-client/commit/341e17c087105b7cccd1609ad3df2cb15e10f1dc) - Fix Vue `useSuspense()` suspending on stale data instead of showing it while it refetches
|
|
350
|
+
|
|
351
|
+
When a component mounted with cached data that was past its `dataExpiryLength` but still valid, `await useSuspense()`
|
|
352
|
+
waited for the refetch, so users saw the `<Suspense>` fallback instead of the data already on hand. Now, like React,
|
|
353
|
+
it renders the stale data right away and updates once the refetch resolves. Data that is missing, invalidated, or
|
|
354
|
+
[invalidIfStale](https://dataclient.io/rest/api/Endpoint#invalidifstale) still waits for the fetch.
|
|
355
|
+
|
|
356
|
+
- [#4150](https://github.com/reactive/data-client/pull/4150) [`74e67fa`](https://github.com/reactive/data-client/commit/74e67fa2c4f9f104f5b7a49e877a48e5963e4bd2) - Vue `useFetch()` keeps its response from being garbage collected while mounted, like React `useFetch()` and Vue `useSuspense()`
|
|
357
|
+
|
|
358
|
+
- [#4114](https://github.com/reactive/data-client/pull/4114) [`7c24b70`](https://github.com/reactive/data-client/commit/7c24b706360208e167aff5d576ad679f7e8e2138) - Fix [useFetch()](https://dataclient.io/docs/api/useFetch) return type to be a read-only `Ref`
|
|
359
|
+
|
|
360
|
+
`useFetch()` returns a read-only `Ref` holding the fetch promise, but was typed as returning the promise directly.
|
|
361
|
+
|
|
362
|
+
```ts
|
|
363
|
+
const promise = useFetch(PostResource.get, { id });
|
|
364
|
+
// Before: promise.resolved typechecked, but was always undefined at runtime
|
|
365
|
+
// After:
|
|
366
|
+
if (!promise.value.resolved) {
|
|
367
|
+
// fetch is in-flight
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
- Updated dependencies [[`46f1f24`](https://github.com/reactive/data-client/commit/46f1f24bcb04824805747ed2a1effe7baece337c), [`a82758c`](https://github.com/reactive/data-client/commit/a82758cd1998e58d7ad280407db28bd84f5d7b18), [`b55696c`](https://github.com/reactive/data-client/commit/b55696c72ad3e73e0a2f50d3751c7104cd4ad9ee), [`74e67fa`](https://github.com/reactive/data-client/commit/74e67fa2c4f9f104f5b7a49e877a48e5963e4bd2), [`159c963`](https://github.com/reactive/data-client/commit/159c9633679d95427fe4f626aec341c76e4578f8), [`47502c6`](https://github.com/reactive/data-client/commit/47502c664df913297fba3e5011a975dfd01c0d8d), [`fc4b015`](https://github.com/reactive/data-client/commit/fc4b015ca0899a2685af881d17f765dce27ffc1a), [`aa15f29`](https://github.com/reactive/data-client/commit/aa15f29f6b0a3b4ae655e2d114a419a3fc94ac7e)]:
|
|
372
|
+
- @data-client/core@0.18.2
|
|
373
|
+
|
|
374
|
+
## 0.18.1
|
|
375
|
+
|
|
376
|
+
### Patch Changes
|
|
377
|
+
|
|
378
|
+
- [#3960](https://github.com/reactive/data-client/pull/3960) [`dfa657e`](https://github.com/reactive/data-client/commit/dfa657eb419641845bc7c39abe52189905773190) - Endpoints that resolve to falsy values (`''`, `0`, `false`, or `null`) no longer trigger infinite refetches.
|
|
379
|
+
|
|
380
|
+
- Updated dependencies [[`dfa657e`](https://github.com/reactive/data-client/commit/dfa657eb419641845bc7c39abe52189905773190)]:
|
|
381
|
+
- @data-client/core@0.18.1
|
|
382
|
+
|
|
3
383
|
## 0.18.0
|
|
4
384
|
|
|
5
385
|
### Minor Changes
|
|
@@ -34,7 +414,7 @@
|
|
|
34
414
|
}
|
|
35
415
|
```
|
|
36
416
|
|
|
37
|
-
The new [`IDenormalizeDelegate`](https://dataclient.io/rest/api/
|
|
417
|
+
The new [`IDenormalizeDelegate`](https://dataclient.io/rest/api/SchemaSimple)
|
|
38
418
|
exposes `unvisit`, `args`, and a new `argsKey(fn)` helper that registers
|
|
39
419
|
a memoization dimension when output varies with endpoint args. Reading
|
|
40
420
|
`delegate.args` directly does _not_ contribute to cache invalidation โ
|
package/README.md
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
</div>
|
|
7
7
|
</h1>
|
|
8
8
|
|
|
9
|
-
The scalable way to build applications with [dynamic data](https://dataclient.io/
|
|
9
|
+
The scalable way to build applications with [dynamic data](https://dataclient.io/vue/getting-started/mutations).
|
|
10
10
|
|
|
11
|
-
[Declarative
|
|
12
|
-
<br/>[Performant rendering](https://dataclient.io/
|
|
11
|
+
[Declarative resource definitions](https://dataclient.io/vue/getting-started/resource) for [REST](https://dataclient.io/rest), [GraphQL](https://dataclient.io/graphql), [Websockets+SSE](https://dataclient.io/vue/concepts/managers#data-stream) and [more](https://dataclient.io/rest/api/Endpoint)
|
|
12
|
+
<br/>[Performant rendering](https://dataclient.io/vue/getting-started/data-dependency) in [Vue 3](https://vuejs.org/)
|
|
13
13
|
|
|
14
14
|
Schema driven. Zero updater functions.
|
|
15
15
|
|
|
@@ -24,7 +24,7 @@ Schema driven. Zero updater functions.
|
|
|
24
24
|
[](https://skills.sh/reactive/data-client)
|
|
25
25
|
[](https://discord.gg/35nb8Mz)
|
|
26
26
|
|
|
27
|
-
**[๐Read The Docs](https://dataclient.io/
|
|
27
|
+
**[๐Read The Docs](https://dataclient.io/vue)** | [๐Getting Started](https://dataclient.io/vue/getting-started/agent-skills) | [๐คAgent Skills](https://skills.sh/reactive/data-client) | [๐ฎTodo Demo](https://stackblitz.com/github/reactive/data-client/tree/master/examples/vue-todo-app?file=src%2Fcomponents%2FTodoListContent.vue)
|
|
28
28
|
|
|
29
29
|
</div>
|
|
30
30
|
|
|
@@ -34,7 +34,19 @@ Schema driven. Zero updater functions.
|
|
|
34
34
|
npm install --save @data-client/vue @data-client/rest
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Install [DataClientPlugin](https://dataclient.io/vue/api/DataClientPlugin) when creating your app:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { createApp } from 'vue';
|
|
41
|
+
import { DataClientPlugin } from '@data-client/vue';
|
|
42
|
+
import App from './App.vue';
|
|
43
|
+
|
|
44
|
+
const app = createApp(App);
|
|
45
|
+
app.use(DataClientPlugin);
|
|
46
|
+
app.mount('#app');
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
For more details, see [the Getting Started docs page](https://dataclient.io/vue/getting-started/installation).
|
|
38
50
|
|
|
39
51
|
### Skills
|
|
40
52
|
|
|
@@ -68,7 +80,7 @@ class Article extends Entity {
|
|
|
68
80
|
}
|
|
69
81
|
```
|
|
70
82
|
|
|
71
|
-
### Create [collection of API Endpoints](https://dataclient.io/
|
|
83
|
+
### Create [collection of API Endpoints](https://dataclient.io/vue/getting-started/resource)
|
|
72
84
|
|
|
73
85
|
```typescript
|
|
74
86
|
const UserResource = resource({
|
|
@@ -86,7 +98,7 @@ const ArticleResource = resource({
|
|
|
86
98
|
});
|
|
87
99
|
```
|
|
88
100
|
|
|
89
|
-
### One line [data binding](https://dataclient.io/
|
|
101
|
+
### One line [data binding](https://dataclient.io/vue/getting-started/data-dependency)
|
|
90
102
|
|
|
91
103
|
```vue
|
|
92
104
|
<template>
|
|
@@ -104,7 +116,9 @@ const article = await useSuspense(ArticleResource.get, { id: props.id });
|
|
|
104
116
|
</script>
|
|
105
117
|
```
|
|
106
118
|
|
|
107
|
-
|
|
119
|
+
Components that `await` data render inside Vue's [<Suspense>](https://vuejs.org/guide/built-ins/suspense.html), which shows a fallback while [loading](https://dataclient.io/vue/getting-started/data-dependency#async-fallbacks).
|
|
120
|
+
|
|
121
|
+
### [Reactive Mutations](https://dataclient.io/vue/getting-started/mutations)
|
|
108
122
|
|
|
109
123
|
```vue
|
|
110
124
|
<template>
|
|
@@ -120,7 +134,7 @@ const props = defineProps<{ id: string; article: Article }>();
|
|
|
120
134
|
const ctrl = useController();
|
|
121
135
|
|
|
122
136
|
const handleCreateArticle = (article: Partial<Article>) =>
|
|
123
|
-
ctrl.fetch(ArticleResource.getList.push,
|
|
137
|
+
ctrl.fetch(ArticleResource.getList.push, article);
|
|
124
138
|
|
|
125
139
|
const handleUpdateProfile = (user: Partial<User>) =>
|
|
126
140
|
ctrl.fetch(UserResource.update, { id: props.article.author.id }, user);
|
|
@@ -130,7 +144,7 @@ const handleDeleteArticle = () =>
|
|
|
130
144
|
</script>
|
|
131
145
|
```
|
|
132
146
|
|
|
133
|
-
### [Subscriptions](https://dataclient.io/
|
|
147
|
+
### [Subscriptions](https://dataclient.io/vue/api/useLive)
|
|
134
148
|
|
|
135
149
|
```vue
|
|
136
150
|
<template>
|
|
@@ -139,11 +153,11 @@ const handleDeleteArticle = () =>
|
|
|
139
153
|
|
|
140
154
|
<script setup lang="ts">
|
|
141
155
|
const props = defineProps<{ symbol: string }>();
|
|
142
|
-
const price = useLive(PriceResource.get, { symbol: props.symbol });
|
|
156
|
+
const price = await useLive(PriceResource.get, { symbol: props.symbol });
|
|
143
157
|
</script>
|
|
144
158
|
```
|
|
145
159
|
|
|
146
|
-
### [Type-safe Imperative Actions](https://dataclient.io/
|
|
160
|
+
### [Type-safe Imperative Actions](https://dataclient.io/vue/api/Controller)
|
|
147
161
|
|
|
148
162
|
```typescript
|
|
149
163
|
const ctrl = useController();
|
|
@@ -176,7 +190,7 @@ const groupTodoByUser = new Query(
|
|
|
176
190
|
const todosByUser = useQuery(groupTodoByUser);
|
|
177
191
|
```
|
|
178
192
|
|
|
179
|
-
### [Powerful Middlewares](https://dataclient.io/
|
|
193
|
+
### [Powerful Middlewares](https://dataclient.io/vue/concepts/managers)
|
|
180
194
|
|
|
181
195
|
```ts
|
|
182
196
|
class LoggingManager implements Manager {
|
|
@@ -212,7 +226,7 @@ class TickerStream implements Manager {
|
|
|
212
226
|
}
|
|
213
227
|
```
|
|
214
228
|
|
|
215
|
-
### [Integrated data mocking](https://dataclient.io/
|
|
229
|
+
### [Integrated data mocking](https://dataclient.io/vue/api/Fixtures)
|
|
216
230
|
|
|
217
231
|
```typescript
|
|
218
232
|
import { createApp } from 'vue';
|
|
@@ -221,12 +235,12 @@ import { MockPlugin } from '@data-client/vue/test';
|
|
|
221
235
|
|
|
222
236
|
const app = createApp(App);
|
|
223
237
|
app.use(DataClientPlugin);
|
|
224
|
-
if (
|
|
238
|
+
if (import.meta.env.DEV) {
|
|
225
239
|
app.use(MockPlugin, {
|
|
226
240
|
fixtures: [
|
|
227
241
|
{
|
|
228
242
|
endpoint: ArticleResource.getList,
|
|
229
|
-
args: [{
|
|
243
|
+
args: [{ author: '10' }] as const,
|
|
230
244
|
response: [
|
|
231
245
|
{
|
|
232
246
|
id: '5',
|
|
@@ -259,46 +273,77 @@ app.mount('#app');
|
|
|
259
273
|
|
|
260
274
|
**Note:** `MockPlugin` must be installed after `DataClientPlugin` and before mounting the app.
|
|
261
275
|
|
|
276
|
+
### [Testing composables](https://dataclient.io/vue/guides/unit-testing-composables)
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
import { renderDataCompose } from '@data-client/vue/test';
|
|
280
|
+
|
|
281
|
+
it('useSuspense() resolves an article', async () => {
|
|
282
|
+
const { result, cleanup } = await renderDataCompose(
|
|
283
|
+
() => useSuspense(ArticleResource.get, { id: '5' }),
|
|
284
|
+
{
|
|
285
|
+
initialFixtures: [
|
|
286
|
+
{
|
|
287
|
+
endpoint: ArticleResource.get,
|
|
288
|
+
args: [{ id: '5' }],
|
|
289
|
+
response: { id: '5', title: 'first post', body: 'hi' },
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
},
|
|
293
|
+
);
|
|
294
|
+
const article = await result;
|
|
295
|
+
expect(article.value.title).toBe('first post');
|
|
296
|
+
cleanup();
|
|
297
|
+
});
|
|
298
|
+
```
|
|
299
|
+
|
|
262
300
|
### ...all typed ...fast ...and consistent
|
|
263
301
|
|
|
264
|
-
For the small price of 9kb
|
|
302
|
+
For the small price of 9kb gzipped. [๐Get started now](https://dataclient.io/vue/getting-started/agent-skills)
|
|
265
303
|
|
|
266
304
|
## Features
|
|
267
305
|
|
|
268
306
|
- [x]  Strong [Typescript](https://www.typescriptlang.org/) inference
|
|
269
307
|
- [x] ๐ Vue 3 [Composition API](https://vuejs.org/guide/extras/composition-api-faq.html) composables
|
|
270
|
-
- [x]
|
|
308
|
+
- [x] ๐ Vue [Suspense](https://dataclient.io/vue/getting-started/data-dependency#boundaries) support
|
|
309
|
+
- [x] ๐ฃ [Declarative API](https://dataclient.io/vue/getting-started/data-dependency)
|
|
271
310
|
- [x] ๐ Composition over configuration
|
|
272
|
-
- [x] ๐ฐ [Normalized](https://dataclient.io/
|
|
311
|
+
- [x] ๐ฐ [Normalized](https://dataclient.io/vue/concepts/normalization) caching
|
|
273
312
|
- [x] ๐ฅ Tiny bundle footprint
|
|
274
313
|
- [x] ๐ Automatic overfetching elimination
|
|
275
314
|
- [x] โจ Fast [optimistic updates](https://dataclient.io/rest/guides/optimistic-updates)
|
|
276
|
-
- [x] ๐ง [Flexible](https://dataclient.io/
|
|
277
|
-
- [x] ๐ง [Debugging and inspection](https://dataclient.io/
|
|
315
|
+
- [x] ๐ง [Flexible](https://dataclient.io/vue/getting-started/resource) to fit any API design (one size fits all)
|
|
316
|
+
- [x] ๐ง [Debugging and inspection](https://dataclient.io/vue/getting-started/debugging) via browser extension
|
|
278
317
|
- [x] ๐ณ Tree-shakable (only use what you need)
|
|
279
|
-
- [x] ๐ [Subscriptions](https://dataclient.io/
|
|
280
|
-
- [x]
|
|
281
|
-
- [x] ๐ฏ [Declarative cache lifetime policy](https://dataclient.io/
|
|
282
|
-
- [x]
|
|
318
|
+
- [x] ๐ [Subscriptions](https://dataclient.io/vue/api/useSubscription)
|
|
319
|
+
- [x] ๐งช [Fixture mocking](https://dataclient.io/vue/api/Fixtures) for [tests](https://dataclient.io/vue/guides/unit-testing-components) and development
|
|
320
|
+
- [x] ๐ฏ [Declarative cache lifetime policy](https://dataclient.io/vue/concepts/expiry-policy)
|
|
321
|
+
- [x] ๐๏ธ Automatic [garbage collection](https://dataclient.io/vue/api/DataClientPlugin#gcPolicy) of unused data
|
|
322
|
+
- [x] ๐ง
[Composable middlewares](https://dataclient.io/vue/api/Manager)
|
|
283
323
|
- [x] ๐ฝ Global data consistency guarantees
|
|
284
324
|
- [x] ๐ Automatic race condition elimination
|
|
285
325
|
- [x] ๐ฏ Global referential equality guarantees
|
|
286
326
|
|
|
327
|
+
## Examples
|
|
328
|
+
|
|
329
|
+
- Todo: [](https://github.com/reactive/data-client/tree/master/examples/vue-todo-app) | [](https://stackblitz.com/github/reactive/data-client/tree/master/examples/vue-todo-app?file=src%2Fcomponents%2FTodoListContent.vue)
|
|
330
|
+
|
|
287
331
|
## API
|
|
288
332
|
|
|
289
|
-
-
|
|
290
|
-
-
|
|
291
|
-
|
|
292
|
-
-
|
|
293
|
-
-
|
|
294
|
-
-
|
|
295
|
-
-
|
|
296
|
-
-
|
|
297
|
-
-
|
|
298
|
-
-
|
|
299
|
-
-
|
|
300
|
-
-
|
|
301
|
-
-
|
|
302
|
-
-
|
|
303
|
-
-
|
|
304
|
-
- Middleware:
|
|
333
|
+
- Setup: [DataClientPlugin](https://dataclient.io/vue/api/DataClientPlugin), [getDefaultManagers()](https://dataclient.io/vue/api/getDefaultManagers)
|
|
334
|
+
- Rendering: [useSuspense()](https://dataclient.io/vue/api/useSuspense), [useLive()](https://dataclient.io/vue/api/useLive), [useCache()](https://dataclient.io/vue/api/useCache), [useDLE()](https://dataclient.io/vue/api/useDLE), [useQuery()](https://dataclient.io/vue/api/useQuery), [useFetch()](https://dataclient.io/vue/api/useFetch), [useSubscription()](https://dataclient.io/vue/api/useSubscription), [useLoading()](https://dataclient.io/vue/api/useLoading), [useDebounce()](https://dataclient.io/vue/api/useDebounce)
|
|
335
|
+
- Event handling: [useController()](https://dataclient.io/vue/api/useController) returns [Controller](https://dataclient.io/vue/api/Controller)
|
|
336
|
+
- [ctrl.fetch](https://dataclient.io/vue/api/Controller#fetch)
|
|
337
|
+
- [ctrl.fetchIfStale](https://dataclient.io/vue/api/Controller#fetchIfStale)
|
|
338
|
+
- [ctrl.expireAll](https://dataclient.io/vue/api/Controller#expireAll)
|
|
339
|
+
- [ctrl.invalidate](https://dataclient.io/vue/api/Controller#invalidate)
|
|
340
|
+
- [ctrl.invalidateAll](https://dataclient.io/vue/api/Controller#invalidateAll)
|
|
341
|
+
- [ctrl.resetEntireStore](https://dataclient.io/vue/api/Controller#resetEntireStore)
|
|
342
|
+
- [ctrl.set](https://dataclient.io/vue/api/Controller#set)
|
|
343
|
+
- [ctrl.setResponse](https://dataclient.io/vue/api/Controller#setResponse)
|
|
344
|
+
- [ctrl.setError](https://dataclient.io/vue/api/Controller#setError)
|
|
345
|
+
- [ctrl.resolve](https://dataclient.io/vue/api/Controller#resolve)
|
|
346
|
+
- [ctrl.subscribe](https://dataclient.io/vue/api/Controller#subscribe)
|
|
347
|
+
- [ctrl.unsubscribe](https://dataclient.io/vue/api/Controller#unsubscribe)
|
|
348
|
+
- Middleware: [LogoutManager](https://dataclient.io/vue/api/LogoutManager), [NetworkManager](https://dataclient.io/vue/api/NetworkManager), [SubscriptionManager](https://dataclient.io/vue/api/SubscriptionManager), [PollingSubscription](https://dataclient.io/vue/api/PollingSubscription), [DevToolsManager](https://dataclient.io/vue/api/DevToolsManager)
|
|
349
|
+
- Testing (`@data-client/vue/test`): [mountDataClient()](https://dataclient.io/vue/guides/unit-testing-components), [renderDataCompose()](https://dataclient.io/vue/guides/unit-testing-composables), `MockPlugin`, [mockInitialState()](https://dataclient.io/vue/api/mockInitialState)
|