reactive/data-client / .agents/skills/data-client-react
data-client-react
UnverifiedRead, change and render async and shared state in React with @data-client/react: any data from an API or other async source, and global state shared across components (it has to persist somewhere, which makes it async). Use it for loading and error states, mutations and forms, filtered or derived views, and debugging data that looks wrong or stale on screen. Use it in place of fetch in useEffect, or app-wide useState and context; its main hooks are useSuspense, useQuery and useController.
references/Actions.md
View on GitHub<!-- Generated by `yarn build:skills` from docs/core/api/Actions.md (react). Edit the source doc, not this file. -->
# Actions
Actions are minimal descriptions of store updates.
They are [dispatched by Controller methods](./Controller.md#action-dispatchers) ->
[read and consumed by Manager middleware](https://dataclient.io/docs/api/Manager#reading-and-consuming-actions) ->
processed by [reducers](https://react.dev/reference/react/useReducer) registered with [DataProvider](./DataProvider.md)
to update the store's state.
Many actions use the same meta information:
```ts
interface ActionMeta {
readonly fetchedAt: number;
readonly date: number;
readonly expiresAt: number;
}
```
## FETCH
```ts
interface FetchMeta {
fetchedAt: number;
resolve: (value?: any | PromiseLike<any>) => void;
reject: (reason?: any) => void;
promise: Promise<any>;
}
interface FetchAction {
type: typeof actionTypes.FETCH;
endpoint: Endpoint;
args: readonly [...Parameters<Endpoint>];
key: string;
meta: FetchMeta;
}
```
```js
{
type: 'rdc/fetch',
key: 'GET https://jsonplaceholder.typicode.com/todos?userId=1',
args: [
{
userId: 1
}
],
endpoint: Endpoint('User.getList'),
meta: {
fetchedAt: '5:09:41.975 PM',
resolve: function (){},
reject: function (){},
promise: {}
}
}
```
Sent by [Controller.fetch()](./Controller.md#fetch), [Controller.fetchIfStale()](./Controller.md#fetchIfStale),
[useSuspense()](./useSuspense.md), [useDLE()](./useDLE.md), [useLive()](./useLive.md), [useFetch()](./useFetch.md)
Read by [NetworkManager](https://dataclient.io/docs/api/NetworkManager)
## SET
```ts
interface SetAction {
type: typeof actionTypes.SET;
schema: Queryable;
args: readonly any[];
meta: ActionMeta;
value: {} | ((previousValue: Denormalize<Queryable>) => {});
}
```
```js
{
type: 'rdc/set',
value: {
userId: 1,
id: 1,
title: 'delectus aut autem',
completed: true
},
args: [
{
id: 1
}
],
schema: Todo,
meta: {
fetchedAt: '5:18:26.394 PM',
date: '5:18:26.636 PM',
expiresAt: '6:18:26.636 PM'
}
}
```
Sent by [Controller.set()](./Controller.md#set)
## SET\_RESPONSE
```ts
interface SetResponseAction {
type: typeof actionTypes.SET_RESPONSE;
endpoint: Endpoint;
args: readonly any[];
key: string;
meta: ActionMeta;
response: ResolveType<Endpoint> | Error;
error: boolean;
}
```
```js
{
type: 'rdc/setresponse',
key: 'PATCH https://jsonplaceholder.typicode.com/todos/1',
response: {
userId: 1,
id: 1,
title: 'delectus aut autem',
completed: true
},
args: [
{
id: 1
},
{
completed: true
}
],
endpoint: Endpoint('Todo.partialUpdate'),
meta: {
fetchedAt: '5:18:26.394 PM',
date: '5:18:26.636 PM',
expiresAt: '6:18:26.636 PM'
},
error: false
}
```
Sent by [Controller.setResponse()](./Controller.md#setResponse), [NetworkManager](https://dataclient.io/docs/api/NetworkManager)
Read by [NetworkManager](https://dataclient.io/docs/api/NetworkManager), [LogoutManager](https://dataclient.io/docs/api/LogoutManager)
## RESET
```ts
interface ResetAction {
type: typeof actionTypes.RESET;
date: number;
}
```
```js
{
type: 'rdc/reset',
date: '5:09:41.975 PM',
}
```
Sent by [Controller.resetEntireStore()](./Controller.md#resetEntireStore)
Read by [NetworkManager](https://dataclient.io/docs/api/NetworkManager)
## SUBSCRIBE
```ts
interface SubscribeAction {
type: typeof actionTypes.SUBSCRIBE;
endpoint: Endpoint;
args: readonly any[];
key: string;
}
```
```js
{
type: 'rdc/subscribe',
key: 'GET https://api.exchange.coinbase.com/products/BTC-USD/ticker',
args: [
{
product_id: 'BTC-USD'
}
],
endpoint: Endpoint('https://api.exchange.coinbase.com/products/:product_id/ticker'),
}
```
Sent by [Controller.subscribe()](./Controller.md#subscribe), [useSubscription()](./useSubscription.md), [useLive()](./useLive.md)
Read by [SubscriptionManager](https://dataclient.io/docs/api/SubscriptionManager)
## UNSUBSCRIBE
```ts
interface UnsubscribeAction {
type: typeof actionTypes.UNSUBSCRIBE;
endpoint: Endpoint;
args: readonly any[];
key: string;
}
```
```js
{
type: 'rdc/unsubscribe',
key: 'GET https://api.exchange.coinbase.com/products/BTC-USD/ticker',
args: [
{
product_id: 'BTC-USD'
}
],
endpoint: Endpoint('https://api.exchange.coinbase.com/products/:product_id/ticker'),
}
```
Sent by [Controller.unsubscribe()](./Controller.md#unsubscribe), [useSubscription()](./useSubscription.md), [useLive()](./useLive.md)
Read by [SubscriptionManager](https://dataclient.io/docs/api/SubscriptionManager)
## INVALIDATE
```ts
interface InvalidateAction {
type: typeof actionTypes.INVALIDATE;
key: string;
}
```
```js
{
type: 'rdc/invalidate',
key: 'GET https://jsonplaceholder.typicode.com/todos?userId=1',
}
```
Sent by [Controller.invalidate()](./Controller.md#invalidate)
## INVALIDATEALL
```ts
interface InvalidateAllAction {
type: typeof actionTypes.INVALIDATEALL;
testKey: (key: string) => boolean;
}
```
```js
{
type: 'rdc/invalidateall',
testKey: Endpoint('User.getList'),
}
```
Sent by [Controller.invalidateAll()](./Controller.md#invalidateAll)
## EXPIREALL
```ts
interface ExpireAllAction {
type: typeof actionTypes.EXPIREALL;
testKey: (key: string) => boolean;
}
```
```js
{
type: 'rdc/expireall',
testKey: Endpoint('User.getList'),
}
```
Sent by [Controller.expireAll()](./Controller.md#expireAll)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |