react-query#FetchQueryOptions TypeScript Examples
The following examples show how to use
react-query#FetchQueryOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts From tailchat with GNU General Public License v3.0 | 7 votes |
/**
* 构建缓存请求
* TODO: 这里的类型真的不好写, 先用any来过滤内部的, 只保证外部使用ok
*
* @example
* const queryData = buildCachedRequest('key', (arg1, arg2) => {
* return request.post(...)
* })
*/
export function buildCachedRequest<
R extends any,
F extends (...args: any) => Promise<R>
>(name: string, fn: F, options?: FetchQueryOptions): F {
return ((...args: any) => {
return queryClient.fetchQuery(
[name, JSON.stringify(args)],
() => fn(...args),
options
);
}) as any;
}