import type { UseAsyncFnReturns } from '@shined/react-use'; import type { AnyFunc } from "../../utils/index.cjs"; export interface UseAsyncFnExtendReturns extends UseAsyncFnReturns { /** * Set the loading state * * @param {boolean} value - `boolean`, the loading value to set * @returns {void} `void` */ setLoading: (value: boolean) => void; } export interface CreateSingleLoadingReturns { /** * A Hook in React to use bound async function with loading state * * @param {AnyFunc} asyncFn - `AnyFunc`, the async function to bind, see {@link AnyFunc} * @returns {UseAsyncFnExtendReturns} see {@link UseAsyncFnExtendReturns} */ useAsyncFn: (asyncFn: T) => UseAsyncFnExtendReturns; /** * A Hook in React to use loading state * * @returns {boolean} `boolean`, the loading state */ useLoading(): boolean; /** * Set the loading state via store in JS/TS * * @param {boolean} value - `boolean`, the value to set * @returns {void} `void` */ set: (value: boolean) => void; /** * Get the loading state via store in JS/TS * * @returns {boolean} `boolean`, the loading state */ get(): boolean; /** * Bind the loading state to the async function in JS/TS * * @param {AnyFunc} asyncFn - `AnyFunc`, the async function to bind, see {@link AnyFunc} * @returns {AnyFunc} `AnyFunc`, same as `asyncFn` param, see {@link AnyFunc} */ bind: (asyncFn: T) => T; } export interface CreateSingleLoadingOptions { /** * Whether set to false on error * * @defaultValue true */ resetOnError?: boolean; /** * Initial loading state * * @defaultValue false */ initialValue?: boolean; } /** * A utility that provide a way to manage single (or global) loading state via multiple Hooks or simple JS/TS functions, using [Reactive](https://sheinsight.github.io/reactive/) under the hood. * * You need to install `@shined/react-use` to use this utility. * * @param {CreateSingleLoadingOptions} options {@link CreateSingleLoadingOptions} * @returns {CreateSingleLoadingReturns} `CreateSingleLoadingReturns`, single loading instance, see {@link CreateSingleLoadingReturns} * * @see {@link https://sheinsight.github.io/react-use/ | React Use - Documentation} */ export declare function createSingleLoading(options?: CreateSingleLoadingOptions): CreateSingleLoadingReturns; //# sourceMappingURL=index.d.cts.map