@daysnap/utils
Version:
15 lines (12 loc) • 595 B
TypeScript
import { Loose } from '@daysnap/types';
type WithFalse<T> = T | false;
/**
* loading 生成器
* const withLoading = createWithLoading(() => showLoading())
* const fn = withLoading(async () => { // ... })
* fn() 执行的时候就会执行showLoading
*/
declare function createWithLoading<O = any>(showLoading: (options: O) => Loose<{
close: () => any;
}>, defaultOptions?: O): <T extends (...args: any[]) => Promise<any>>(fn: T, options?: WithFalse<O>) => (...params: [...Parameters<T>, (WithFalse<O> | undefined)?]) => Promise<Awaited<ReturnType<T>>>;
export { createWithLoading };