nuxt
Version:
39 lines (38 loc) • 1.26 kB
TypeScript
import { ShallowRef } from "vue";
//#region src/app/composables/loading-indicator.d.ts
type LoadingIndicatorOpts = {
/** @default 2000 */duration: number; /** @default 200 */
throttle: number; /** @default 500 */
hideDelay: number; /** @default 400 */
resetDelay: number;
/**
* You can provide a custom function to customize the progress estimation,
* which is a function that receives the duration of the loading bar (above)
* and the elapsed time. It should return a value between 0 and 100.
*/
estimatedProgress?: (duration: number, elapsed: number) => number;
};
type LoadingIndicator = {
_cleanup: () => void;
progress: Readonly<ShallowRef<number>>;
isLoading: Readonly<ShallowRef<boolean>>;
error: Readonly<ShallowRef<boolean>>;
start: (opts?: {
force?: boolean;
}) => void;
set: (value: number, opts?: {
force?: boolean;
}) => void;
finish: (opts?: {
force?: boolean;
error?: boolean;
}) => void;
clear: () => void;
};
/**
* composable to handle the loading state of the page
* @since 3.9.0
*/
declare function useLoadingIndicator(opts?: Partial<LoadingIndicatorOpts>): Omit<LoadingIndicator, '_cleanup'>;
//#endregion
export { LoadingIndicator, LoadingIndicatorOpts, useLoadingIndicator };