create-lazy-module
v1.0.1
Published
Create lazy module that enqueue calls while the original module is loading and dequeue calls when it is loaded.
Readme
Create Lazy Module
Create lazy module that enqueue calls while the original module is loading and dequeue calls when it is loaded.
Installation
yarn add create-lazy-moduleAPI
import { createLazyModule } from 'create-lazy-module';
const loadOriginalModule = () => import('./analytics');
const methodNames = ['track'];
const [lazyModule, loadModule] = createLazyModule(
loadOriginalModule,
methodNames
);Parameters
loadOriginalModule:() => Promise<OriginalModule>, Returns a Promise resolving with the original module.methodNames:string[], Methods that are available on the lazy module.
Return
lazyModule:LazyModule, Lazy module with methods defined inmethodNames.loadModule:() => Promise<void>, Loads the original module and dequeue calls.
