@studiometa/js-toolkit
Version:
A set of useful little bits of JavaScript to boost your project! 🚀
19 lines (18 loc) • 594 B
TypeScript
import type { BaseConstructor } from '../Base/index.js';
type ImportWhenIdleOptions = {
timeout?: number;
};
/**
* Import a component when user is idle.
*
* @template {BaseConstructor} T
* @param {() => Promise<T|{default:T}>} fn
* The import function.
* @param {ImportWhenIdleOptions} [options]
* The time to wait before triggering the callback if never idle.
* @returns {Promise<T>}
*/
export declare function importWhenIdle<T extends BaseConstructor = BaseConstructor>(fn: () => Promise<T | {
default: T;
}>, { timeout }?: ImportWhenIdleOptions): Promise<T>;
export {};