Skip to content

Commit

Permalink
Update usage-without-react-hooks.mdx
Browse files Browse the repository at this point in the history
Add examples of what you can do with the subscription in the first subscribe code example
  • Loading branch information
Azeirah authored Oct 2, 2023
1 parent 52ab548 commit b3d66a0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/rtk-query/usage/usage-without-react-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ Cache subscriptions are used to tell RTK Query that it needs to fetch data for a
With React hooks, this behavior is instead handled within [`useQuery`](../api/created-api/hooks.mdx#usequery), [`useQuerySubscription`](../api/created-api/hooks.mdx#usequerysubscription), [`useLazyQuery`](../api/created-api/hooks.mdx#uselazyquery), and [`useLazyQuerySubscription`](../api/created-api/hooks.mdx#uselazyquerysubscription).

```ts title="Subscribing to cached data" no-transpile
dispatch(api.endpoints.getPosts.initiate())
const subscription = dispatch(api.endpoints.getPosts.initiate())
// The subscription contains the same methods as you would find in the hook
// ...subscription.refetch();
// ...subscription.isLoading;
```

## Removing a subscription
Expand Down

0 comments on commit b3d66a0

Please sign in to comment.