Skip to content

Commit cd86993

Browse files
committed
docs: Remove 0.2 features from 0.9 announcement
1 parent 376ce20 commit cd86993

File tree

2 files changed

+75
-128
lines changed

2 files changed

+75
-128
lines changed

website/blog/2023-07-04-v0.2-release-announcement.md

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ description: 0.2 of Data Client makes list mutation much easier, as Collection S
77

88
import HooksPlayground from '@site/src/components/HooksPlayground';
99
import { todoFixtures } from '@site/src/fixtures/todos';
10+
import DiffEditor from '@site/src/components/DiffEditor';
1011

1112
[Collections](/rest/api/Collection) enable Arrays and Objects to be easily
1213
extended by [pushing](/rest/api/Collection#push) or [unshifting](/rest/api/Collection#unshift) new
@@ -249,33 +250,35 @@ Upgrading can be done gradually as all changes were initially released in `/next
249250

250251
BREAKING: Calling super.getRequestInit() will return a promise - so you must resolve it:
251252

252-
```ts
253-
class AuthdEndpoint<
254-
O extends RestGenerics = any,
255-
> extends RestEndpoint<O> {
256-
getRequestInit(body: any): RequestInit {
257-
return {
258-
...super.getRequestInit(body),
259-
credentials: 'same-origin',
260-
};
261-
}
253+
<DiffEditor>
254+
255+
```ts title="Before"
256+
class AuthdEndpoint<
257+
O extends RestGenerics = any,
258+
> extends RestEndpoint<O> {
259+
getRequestInit(body: any): RequestInit {
260+
return {
261+
...super.getRequestInit(body),
262+
credentials: 'same-origin',
263+
};
262264
}
263-
```
264-
265-
->
265+
}
266+
```
266267

267-
```ts
268-
class AuthdEndpoint<
269-
O extends RestGenerics = any,
270-
> extends RestEndpoint<O> {
271-
async getRequestInit(body: any): Promise<RequestInit> {
272-
return {
273-
...(await super.getRequestInit(body)),
274-
credentials: 'same-origin',
275-
};
276-
}
268+
```ts title="After"
269+
class AuthdEndpoint<
270+
O extends RestGenerics = any,
271+
> extends RestEndpoint<O> {
272+
async getRequestInit(body: any): Promise<RequestInit> {
273+
return {
274+
...(await super.getRequestInit(body)),
275+
credentials: 'same-origin',
276+
};
277277
}
278-
```
278+
}
279+
```
280+
281+
</DiffEditor>
279282

280283
- createResource().getList uses a Collection, which .create appends to [2593](https://github.com/reactive/data-client/pull/2593)
281284
- `Resource.create` will automatically add to the list

website/blog/2024-01-15-v0.9-release-announcement.md

Lines changed: 48 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
---
2-
title: "v0.9: Collections, DevTools, and Legacy Cleanup"
2+
title: "v0.9: DevTools, Resource.extend, and Legacy Cleanup"
33
authors: [ntucker]
4-
tags: [releases, rest, resource, endpoint, collection]
5-
description: Data Client 0.9 brings Collections for automatic list management, improved DevTools experience, and removes legacy APIs for a cleaner, faster library.
4+
tags: [releases, rest, resource, endpoint]
5+
description: Data Client 0.9 brings improved DevTools experience, Resource.extend() for customization, new controller methods, and removes legacy APIs for a cleaner, faster library.
66
---
77

88
import Link from '@docusaurus/Link';
99

10-
[Collections](/rest/api/Collection) are the highlight of this release - automatically managing list updates when
11-
creating, updating, or deleting entities. Combined with [Resource.extend()](/rest/api/resource#extend),
12-
building CRUD operations has never been simpler.
10+
This release focuses on developer experience with a [devtools button](/blog/2024/01/15/v0.9-release-announcement#devtools-button) that appears in development
11+
mode, better [DevTools history](/blog/2024/01/15/v0.9-release-announcement#devtools-improvements), and new controller methods like
12+
[controller.expireAll()](/blog/2024/01/15/v0.9-release-announcement#controllerexpireall) and [controller.fetchIfStale()](/blog/2024/01/15/v0.9-release-announcement#controllerfetchifstale).
13+
14+
[Resource.extend()](/rest/api/resource#extend) provides three powerful ways to customize resources - adding new endpoints,
15+
overriding existing ones, or deriving from base endpoints.
1316

1417
```ts
15-
const TodoResource = createResource({
16-
path: '/todos/:id',
17-
schema: Todo,
18+
const UserResource = createResource({
19+
path: '/users/:id',
20+
schema: User,
21+
}).extend('current', {
22+
path: '/users/current',
1823
});
19-
// POST /todos - automatically adds to all matching collections
20-
ctrl.fetch(TodoResource.getList.push, { title: 'My new todo', userId });
2124
```
2225

23-
We've also improved the developer experience with a [devtools button](/blog/2024/01/15/v0.9-release-announcement#devtools-button) that appears in development
24-
mode, better [DevTools history](/blog/2024/01/15/v0.9-release-announcement#devtools-improvements), and new controller methods like
25-
[controller.expireAll()](/blog/2024/01/15/v0.9-release-announcement#controllerexpireall) and [controller.fetchIfStale()](/blog/2024/01/15/v0.9-release-announcement#controllerfetchifstale).
26-
2726
<center>
2827

2928
<Link className="button button--secondary" to="/blog/2024/01/15/v0.9-release-announcement#migration-guide">Migration guide</Link>
@@ -44,56 +43,7 @@ mode, better [DevTools history](/blog/2024/01/15/v0.9-release-announcement#devto
4443
import DiffEditor from '@site/src/components/DiffEditor';
4544
import PkgTabs from '@site/src/components/PkgTabs';
4645

47-
## Collections
48-
49-
[Collections](/rest/api/Collection) automatically update when mutations occur, eliminating the need for
50-
manual [Endpoint.update](/rest/api/Endpoint#update). When you use [createResource](/rest/api/resource),
51-
the `getList` endpoint automatically uses a Collection schema.
52-
53-
```ts
54-
const TodoResource = createResource({
55-
path: '/todos/:id',
56-
schema: Todo,
57-
});
58-
59-
// getList.push creates and adds to the collection
60-
ctrl.fetch(TodoResource.getList.push, { title: 'My new todo', userId: 1 });
61-
62-
// getList.unshift adds to the beginning
63-
ctrl.fetch(TodoResource.getList.unshift, { title: 'Priority todo', userId: 1 });
64-
```
65-
66-
Collections intelligently match based on arguments, so a todo created with `userId: 1` will only
67-
appear in collections that were fetched with that same user filter.
68-
69-
### Collection with FormData
70-
71-
[Collections](/rest/api/Collection) can filter based on FormData arguments. [f95dbc6](https://github.com/reactive/data-client/commit/f95dbc64d1)
72-
73-
```ts
74-
ctrl.fetch(getPosts.push, { group: 'react' }, new FormData(e.currentTarget));
75-
```
76-
77-
If the FormData contains an `author` field, the newly created item will be properly added to
78-
collections filtered by that author.
79-
80-
### Pagination with Collections
81-
82-
Use [paginationField](/rest/api/RestEndpoint#paginationfield) for easy pagination support.
83-
[c8c557](https://github.com/reactive/data-client/commit/c8c5575e5a)
84-
85-
```ts
86-
const TodoResource = createResource({
87-
path: '/todos/:id',
88-
schema: Todo,
89-
paginationField: 'page',
90-
});
91-
92-
// Fetches page 2 and appends to the collection
93-
ctrl.fetch(TodoResource.getList.getPage, { page: '2' });
94-
```
95-
96-
## Resource.extend()
46+
## Resource.extend() <small>(since 0.5)</small>
9747

9848
[Resource.extend()](/rest/api/resource#extend) provides three powerful ways to customize resources.
9949
[51b4b0d](https://github.com/reactive/data-client/commit/51b4b0d188)
@@ -134,7 +84,7 @@ const IssueResource = createResource({
13484

13585
## Controller Methods
13686

137-
### controller.expireAll()
87+
### controller.expireAll() <small>(since 0.3)</small>
13888

13989
Sets all matching responses to *stale*, triggering background refetch while showing existing data.
14090
[#2802](https://github.com/reactive/data-client/pull/2802)
@@ -147,7 +97,7 @@ controller.expireAll(ArticleResource.getList);
14797
This differs from `invalidateAll()` which removes the data entirely. `expireAll()` keeps showing
14898
the cached data while fetching fresh data in the background.
14999

150-
### controller.fetchIfStale()
100+
### controller.fetchIfStale() <small>(since 0.4)</small>
151101

152102
Fetches only if data is considered stale; otherwise returns the cached data.
153103
[#2804](https://github.com/reactive/data-client/pull/2804)
@@ -198,15 +148,42 @@ When devtools are open, a shadow state accurately reflects changes from each act
198148
Endpoint properties are now fully visible in the devtool inspector.
199149
[a7da00e](https://github.com/reactive/data-client/commit/a7da00e82d)
200150

151+
## Collection Enhancements
152+
153+
### FormData argument filtering <small>(since 0.4)</small>
154+
155+
[Collections](/rest/api/Collection) can now filter based on FormData arguments. [f95dbc6](https://github.com/reactive/data-client/commit/f95dbc64d1)
156+
157+
```ts
158+
ctrl.fetch(getPosts.push, { group: 'react' }, new FormData(e.currentTarget));
159+
```
160+
161+
If the FormData contains an `author` field, the newly created item will be properly added to
162+
collections filtered by that author.
163+
164+
### paginationField <small>(since 0.7)</small>
165+
166+
Use [paginationField](/rest/api/RestEndpoint#paginationfield) for easy pagination support.
167+
[c8c557](https://github.com/reactive/data-client/commit/c8c5575e5a)
168+
169+
```ts
170+
const TodoResource = createResource({
171+
path: '/todos/:id',
172+
schema: Todo,
173+
paginationField: 'page',
174+
});
175+
176+
// Fetches page 2 and appends to the collection
177+
ctrl.fetch(TodoResource.getList.getPage, { page: '2' });
178+
```
179+
201180
## Other Improvements
202181

203182
- Add `className` to ErrorBoundary and `errorClassName` to [AsyncBoundary](/docs/api/AsyncBoundary) [#2785](https://github.com/reactive/data-client/pull/2785)
204183
- New `getDefaultManagers()` export for explicit manager control [#2791](https://github.com/reactive/data-client/pull/2791)
205184
- Replace BackupBoundary with UniversalSuspense + BackupLoading [#2803](https://github.com/reactive/data-client/pull/2803)
206-
- Entity.process() receives endpoint `args` as fourth parameter [a8936f5](https://github.com/reactive/data-client/commit/a8936f5e6d)
207-
- `nonFilterArgumentKeys` for Collection to exclude sort/order params from filtering [318df89](https://github.com/reactive/data-client/commit/318df89bf7)
208-
- Support `+` and `*` modifiers in [RestEndpoint.path](/rest/api/RestEndpoint#path) [a6b4f4a](https://github.com/reactive/data-client/commit/a6b4f4aabbfd06f5106a96e809a6c1a5e7045172)
209-
- Support `{}` grouping in path for optional segments [a6b4f4a](https://github.com/reactive/data-client/commit/a6b4f4aabbfd06f5106a96e809a6c1a5e7045172)
185+
- Entity.process() receives endpoint `args` as fourth parameter *(since 0.7)* [a8936f5](https://github.com/reactive/data-client/commit/a8936f5e6d)
186+
- `nonFilterArgumentKeys` for Collection to exclude sort/order params from filtering *(since 0.7)* [318df89](https://github.com/reactive/data-client/commit/318df89bf7)
210187

211188
## Migration Guide
212189

@@ -394,39 +371,6 @@ const managers = getDefaultManagers();
394371
</CacheProvider>
395372
```
396373

397-
### RestEndpoint.getRequestInit returns Promise
398-
399-
If you override `getRequestInit()`, it now returns a Promise.
400-
[#2792](https://github.com/reactive/data-client/pull/2792)
401-
402-
<DiffEditor>
403-
404-
```ts title="Before"
405-
class AuthdEndpoint<O extends RestGenerics = any> extends RestEndpoint<O> {
406-
// highlight-next-line
407-
getRequestInit(body: any): RequestInit {
408-
return {
409-
...super.getRequestInit(body),
410-
credentials: 'same-origin',
411-
};
412-
}
413-
}
414-
```
415-
416-
```ts title="After"
417-
class AuthdEndpoint<O extends RestGenerics = any> extends RestEndpoint<O> {
418-
// highlight-next-line
419-
async getRequestInit(body: any): Promise<RequestInit> {
420-
return {
421-
...(await super.getRequestInit(body)),
422-
credentials: 'same-origin',
423-
};
424-
}
425-
}
426-
```
427-
428-
</DiffEditor>
429-
430374
### Upgrade support
431375

432376
As usual, if you have any troubles or questions, feel free to join our [![Chat](https://img.shields.io/discord/768254430381735967.svg?style=flat-square&colorB=758ED3)](https://discord.gg/wXGV27xm6t) or [file a bug](https://github.com/reactive/data-client/issues/new/choose)

0 commit comments

Comments
 (0)