floppy-disk 2.11.1 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -297,3 +297,14 @@ export type UseQuery<TKey extends StoreKey = StoreKey, TResponse = any, TData =
|
|
|
297
297
|
* @see https://floppy-disk.vercel.app/docs/api#createquery
|
|
298
298
|
*/
|
|
299
299
|
export declare const createQuery: <TKey extends StoreKey = StoreKey, TResponse = any, TData = TResponse, TError = unknown, TPageParam = any>(queryFn: (key: TKey, state: QueryState<TKey, TResponse, TData, TError, TPageParam>) => Promise<TResponse>, options?: CreateQueryOptions<TKey, TResponse, TData, TError, TPageParam>) => UseQuery<TKey, TResponse, TData, TError, TPageParam>;
|
|
300
|
+
export type ExtractQueryState<T extends UseQuery<any, any, any, any, any>> = {
|
|
301
|
+
loading: Extract<ReturnType<T['get']>, {
|
|
302
|
+
status: 'loading';
|
|
303
|
+
}>;
|
|
304
|
+
success: Extract<ReturnType<T['get']>, {
|
|
305
|
+
status: 'success';
|
|
306
|
+
}>;
|
|
307
|
+
error: Extract<ReturnType<T['get']>, {
|
|
308
|
+
status: 'error';
|
|
309
|
+
}>;
|
|
310
|
+
};
|
|
@@ -176,7 +176,7 @@ export const createQuery = (queryFn, options = {}) => {
|
|
|
176
176
|
});
|
|
177
177
|
const fetch = () => {
|
|
178
178
|
const { responseUpdatedAt } = get();
|
|
179
|
-
const isStale = Date.now() >
|
|
179
|
+
const isStale = !responseUpdatedAt || Date.now() > responseUpdatedAt + staleTime;
|
|
180
180
|
if (!isStale)
|
|
181
181
|
return;
|
|
182
182
|
forceFetch();
|
|
@@ -297,3 +297,14 @@ export type UseQuery<TKey extends StoreKey = StoreKey, TResponse = any, TData =
|
|
|
297
297
|
* @see https://floppy-disk.vercel.app/docs/api#createquery
|
|
298
298
|
*/
|
|
299
299
|
export declare const createQuery: <TKey extends StoreKey = StoreKey, TResponse = any, TData = TResponse, TError = unknown, TPageParam = any>(queryFn: (key: TKey, state: QueryState<TKey, TResponse, TData, TError, TPageParam>) => Promise<TResponse>, options?: CreateQueryOptions<TKey, TResponse, TData, TError, TPageParam>) => UseQuery<TKey, TResponse, TData, TError, TPageParam>;
|
|
300
|
+
export type ExtractQueryState<T extends UseQuery<any, any, any, any, any>> = {
|
|
301
|
+
loading: Extract<ReturnType<T['get']>, {
|
|
302
|
+
status: 'loading';
|
|
303
|
+
}>;
|
|
304
|
+
success: Extract<ReturnType<T['get']>, {
|
|
305
|
+
status: 'success';
|
|
306
|
+
}>;
|
|
307
|
+
error: Extract<ReturnType<T['get']>, {
|
|
308
|
+
status: 'error';
|
|
309
|
+
}>;
|
|
310
|
+
};
|
|
@@ -179,7 +179,7 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
179
179
|
});
|
|
180
180
|
const fetch = () => {
|
|
181
181
|
const { responseUpdatedAt } = get();
|
|
182
|
-
const isStale = Date.now() >
|
|
182
|
+
const isStale = !responseUpdatedAt || Date.now() > responseUpdatedAt + staleTime;
|
|
183
183
|
if (!isStale)
|
|
184
184
|
return;
|
|
185
185
|
forceFetch();
|