Skip to content

Commit

Permalink
docs: Various updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Dec 20, 2024
1 parent d521830 commit 113b2c9
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 85 deletions.
5 changes: 3 additions & 2 deletions docs/core/api/Manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,5 +357,6 @@ export default class CustomSubsManager implements Manager {
By `return Promise.resolve();` instead of calling `next(action)`, we prevent managers listed
after this one from seeing that [action](./Actions.md).

Types: `FETCH`, `SET`, `SET_RESPONSE`, `RESET`, `SUBSCRIBE`,
`UNSUBSCRIBE`, `INVALIDATE`, `INVALIDATEALL`, `EXPIREALL`
Types: [`FETCH`](./Actions.md#fetch), [`SET`](./Actions.md#set), [`SET_RESPONSE`](./Actions.md#set_response),
[`RESET`](./Actions.md#reset), [`SUBSCRIBE`](./Actions.md#subscribe), [`UNSUBSCRIBE`](./Actions.md#unsubscribe),
[`INVALIDATE`](./Actions.md#invalidate), [`INVALIDATEALL`](./Actions.md#invalidateall), [`EXPIREALL`](./Actions.md#expireall)
14 changes: 14 additions & 0 deletions docs/core/api/NetworkManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ it is able to dedupe identical requests if they are made using the throttle flag

:::

## Lifecycle

### Success

import SuccessLifecycle from '../../rest/diagrams/\_endpoint_success_lifecycle.mdx';

<SuccessLifecycle/>

### Error

import ErrorLifecycle from '../../rest/diagrams/\_endpoint_error_lifecycle.mdx';

<ErrorLifecycle/>

## Members

### constructor(\{ dataExpiryLength = 60000, errorExpiryLength = 1000 }) {#constructor}
Expand Down
14 changes: 7 additions & 7 deletions docs/rest/api/Collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,16 +408,16 @@ This is used by these creation schemas to determine which collections to add to.
Default:

```ts
const defaultFilter =
(urlParams: Record<string, any>, body?: Record<string, any>) =>
(collectionKey: Record<string, string>) =>
createCollectionFilter(...args: Args) {
return (collectionKey: Record<string, string>) =>
Object.entries(collectionKey).every(
([key, value]) =>
key.startsWith('order') ||
// double equals lets us compare non-strings and strings
urlParams[key] == value ||
body?.[key] == value,
this.nonFilterArgumentKeys(key) ||
// strings are canonical form. See pk() above for value transformation
`${args[0][key]}` === value ||
`${args[1]?.[key]}` === value,
);
}
```

## Methods
Expand Down
10 changes: 6 additions & 4 deletions docs/rest/diagrams/_endpoint_error_lifecycle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@ flowchart LR
subgraph managers
NetworkManager-->endpoint("endpoint(...args)")
endpoint--rejects-->Controller.resolve
Controller.resolve("Controller.resolve(error)")-->dispatchR("dispatch(SET)")
Controller.resolve("Controller.resolve(error)")-->dispatchR("dispatch(SET_RESPONSE)")
end
managers--FETCH-->reducer:FETCH
Controller.fetch--FETCH-->managers
subgraph reducer:FETCH
optimistic("Endpoint.?getOptimisticResponse()")-->SET
subgraph SET
optimistic("Endpoint.?getOptimisticResponse()")-->SET_RESPONSE
subgraph SET_RESPONSE
normalize(normalize)-->update("Endpoint.update()")
end
end
subgraph reducer:reduceError
direction LR
filterOptimistic(filterOptimistic)-->errorPolicy("Endpoint.errorPolicy()")
end
managers--SET:error-->reducer:reduceError
managers--SET_RESPONSE:error-->reducer:reduceError
click key "/rest/api/Endpoint#key"
click optimistic "/rest/api/Endpoint#getoptimisticresponse"
click update "/rest/api/Endpoint#update"
click errorPolicy "/rest/api/Endpoint#errorpolicy"
click NetworkManager "/docs/api/NetworkManager"
click dispatch "/docs/api/Actions#fetch"
click dispatchR "/docs/api/Actions#set_response"
```
12 changes: 7 additions & 5 deletions docs/rest/diagrams/_endpoint_success_lifecycle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@ flowchart LR
subgraph managers
NetworkManager-->endpoint("endpoint(...args)")
endpoint--resolves-->Controller.resolve
Controller.resolve("Controller.resolve(response)")-->dispatchR("dispatch(SET)")
Controller.resolve("Controller.resolve(response)")-->dispatchR("dispatch(SET_RESPONSE)")
end
managers--FETCH-->reducer:FETCH
Controller.fetch--FETCH-->managers
subgraph reducer:FETCH
optimistic("Endpoint.?getOptimisticResponse()")-->SET
subgraph SET
optimistic("Endpoint.?getOptimisticResponse()")-->SET_RESPONSE
subgraph SET_RESPONSE
normalize(normalize)-->update("Endpoint.update()")
end
end
subgraph reducer:SET
subgraph reducer:SET_RESPONSE
direction LR
normalize2(normalize)-->update2("Endpoint.update()")
end
managers--SET-->reducer:SET
managers--SET_RESPONSE-->reducer:SET_RESPONSE
click key "/rest/api/Endpoint#key"
click NetworkManager "/docs/api/NetworkManager"
click optimistic "/rest/api/Endpoint#getoptimisticresponse"
click update "/rest/api/Endpoint#update"
click update2 "/rest/api/Endpoint#update"
click dispatch "/docs/api/Actions#fetch"
click dispatchR "/docs/api/Actions#set_response"
```
7 changes: 3 additions & 4 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
- [#3141](https://github.com/reactive/data-client/pull/3141) [`d225595`](https://github.com/reactive/data-client/commit/d2255959489b71cfdfcaf4be72fd272231d392f1) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: setResponseAction.payload -> setResponseAction.response

This only affects those writing custom [Managers](https://dataclient.io/docs/concepts/managers) that
inspect `SET_RESPONSE_TYPE` `action.payload`.
handle [SET_RESPONSE](/docs/api/Actions#set_response).

#### Before

Expand Down Expand Up @@ -276,7 +276,7 @@
- [#3141](https://github.com/reactive/data-client/pull/3141) [`d225595`](https://github.com/reactive/data-client/commit/d2255959489b71cfdfcaf4be72fd272231d392f1) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: remove fetchAction.payload

This only affects those writing custom [Managers](https://dataclient.io/docs/concepts/managers) that
inspect `FETCH_TYPE` `action.fetch`.
handle [FETCH](/docs/api/Actions#fetch).

#### Before

Expand All @@ -292,7 +292,7 @@
switch (action.type) {
case FETCH_TYPE:
// consume fetch, and print the resolution
action.fetch().then(response => console.log(response));
action.payload().then(response => console.log(response));
default:
return next(action);
}
Expand All @@ -318,7 +318,6 @@
// consume fetch, and print the resolution
action
.endpoint(...action.meta.args)
.fetch()
.then(response => console.log(response));
default:
return next(action);
Expand Down
7 changes: 3 additions & 4 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
- [#3141](https://github.com/reactive/data-client/pull/3141) [`d225595`](https://github.com/reactive/data-client/commit/d2255959489b71cfdfcaf4be72fd272231d392f1) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: setResponseAction.payload -> setResponseAction.response

This only affects those writing custom [Managers](https://dataclient.io/docs/concepts/managers) that
inspect `SET_RESPONSE_TYPE` `action.payload`.
handle [SET_RESPONSE](/docs/api/Actions#set_response).

#### Before

Expand Down Expand Up @@ -386,7 +386,7 @@
- [#3141](https://github.com/reactive/data-client/pull/3141) [`d225595`](https://github.com/reactive/data-client/commit/d2255959489b71cfdfcaf4be72fd272231d392f1) Thanks [@ntucker](https://github.com/ntucker)! - BREAKING CHANGE: remove fetchAction.payload

This only affects those writing custom [Managers](https://dataclient.io/docs/concepts/managers) that
inspect `FETCH_TYPE` `action.fetch`.
handle [FETCH](/docs/api/Actions#fetch).

#### Before

Expand All @@ -402,7 +402,7 @@
switch (action.type) {
case FETCH_TYPE:
// consume fetch, and print the resolution
action.fetch().then(response => console.log(response));
action.payload().then(response => console.log(response));
default:
return next(action);
}
Expand All @@ -428,7 +428,6 @@
// consume fetch, and print the resolution
action
.endpoint(...action.meta.args)
.fetch()
.then(response => console.log(response));
default:
return next(action);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: 'v0.13: NextJS App Router, ExpoGo, React Native, Redux'
title: 'v0.13: NextJS App Router, ExpoGo, React 19, Redux'
description: Support for NextJS App Router and React 19, while improving comaptibility with React Native and ExpoGo
authors: [ntucker]
tags: [releases, nextjs, expogo, native]
Expand All @@ -12,14 +12,14 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
Platforms:
- NextJS App Router
- ExpoGo
- React 19

Packages moved inside:
- Redux
- Hooks

**Other Improvements**

- React 19 support
- Added [controller.set(Todo, \{ id }, \{ id, completed: false })](/blog/2024/06/17/v0.13-nextjs-app-router-expogo-native#controllerset)
- RestEndpoint.path [supports +, * and \{}](/blog/2024/06/17/v0.13-nextjs-app-router-expogo-native#path-strings)
- Fixed [controller.fetch() return value for Unions](/blog/2024/06/17/v0.13-nextjs-app-router-expogo-native#ctrlfetch-and-unions)
Expand Down
Loading

0 comments on commit 113b2c9

Please sign in to comment.