UNPKG

@pinia/colada-plugin-auto-refetch

Version:

Automatically refetch queries when they become stale in Pinia Colada

47 lines (42 loc) 1.36 kB
import { PiniaColadaPlugin } from '@pinia/colada'; import { MaybeRefOrGetter } from 'vue'; /** * Pinia Colada Auto Refetch plugin. * * Automatically refreshes queries when they become stale. * * @module @pinia/colada-plugin-auto-refetch */ /** * Options for the auto-refetch plugin. */ interface PiniaColadaAutoRefetchOptions { /** * Whether to enable auto refresh by default. * @default false */ autoRefetch?: MaybeRefOrGetter<boolean>; } /** * To store timeouts in the entry extensions. * @internal */ declare const REFETCH_TIMEOUT_KEY: unique symbol; /** * Plugin that automatically refreshes queries when they become stale */ declare function PiniaColadaAutoRefetch(options?: PiniaColadaAutoRefetchOptions): PiniaColadaPlugin; declare module '@pinia/colada' { interface UseQueryOptions<TData, TError, TDataInitial> extends PiniaColadaAutoRefetchOptions { } interface UseQueryOptionsGlobal extends PiniaColadaAutoRefetchOptions { } interface UseQueryEntryExtensions<TData, TError, TDataInitial> { /** * Used to store the timeout for the auto-refetch plugin. * @internal */ [REFETCH_TIMEOUT_KEY]?: ReturnType<typeof setTimeout>; } } export { PiniaColadaAutoRefetch, type PiniaColadaAutoRefetchOptions, REFETCH_TIMEOUT_KEY as _REFETCH_TIMEOUT_KEY };