UNPKG

@jay-js/system

Version:

A powerful and flexible TypeScript library for UI, state management, lazy loading, routing and managing draggable elements in modern web applications.

16 lines (15 loc) 1.02 kB
import type { TLazyModule } from "../types.js"; /** * Creates a lazily loaded module that will be dynamically imported when needed. * * @param {TLazyModule} lazy - Configuration object for the lazy module * @param {string} [lazy.module] - Name of the module to import. If not provided, a unique default name will be generated * @param {() => Promise<any>} lazy.import - Function that returns a promise resolving to the module * @param {Record<string, any>} [lazy.params] - Props to pass to the module when instantiated * @param {boolean} [lazy.collect] - Whether the module can be garbage collected * @param {HTMLElement|DocumentFragment} [lazy.loader] - Custom loader element to show while loading * @param {HTMLElement} [loader] - Optional loader element to show while module is loading * @returns {HTMLElement} Element that will be replaced with the loaded module * @throws {Error} When module configuration is undefined */ export declare function Lazy(lazy: TLazyModule, loader?: HTMLElement): HTMLElement;