Auto-refetch plugin for Spoosh - refetch on focus and reconnect
npm install @spoosh/plugin-refetchAuto-refetch plugin for Spoosh - refetch on window focus and network reconnect.
Documentation · Requirements: TypeScript >= 5.0 · Peer Dependencies: @spoosh/core
``bash`
npm install @spoosh/plugin-refetch
`typescript
import { Spoosh } from "@spoosh/core";
import { refetchPlugin } from "@spoosh/plugin-refetch";
const client = new Spoosh
refetchPlugin({
refetchOnFocus: true,
refetchOnReconnect: true,
}),
]);
// Uses plugin defaults
useRead((api) => api("posts").GET());
// Per-query override
useRead((api) => api("posts").GET(), {
refetchOnFocus: false, // Disable for this query
});
`
| Option | Type | Default | Description |
| -------------------- | --------- | ------- | --------------------------------- |
| refetchOnFocus | boolean | false | Refetch when window regains focus |refetchOnReconnect
| | boolean | false | Refetch when network reconnects |
| Option | Type | Description |
| -------------------- | --------- | ----------------------------------- |
| refetchOnFocus | boolean | Override focus refetch behavior |refetchOnReconnect
| | boolean` | Override reconnect refetch behavior |