Initialized module loaders
get a returned data for a specified module Undefined when this module has not finish loading
get the list of registered modules
Load one or mutiple modules
Load All the modules that have been registered or initialized by this ModuleLoader
Register one or mutiple lazyload module
Generated using TypeDoc
Dynamic load modules by string types
import { DynamicModuleLoader } from '@21epub/dynamic-loader' const loaders = [ { modules: ["module1", "module2"], loader: async () => { await import('url/to/module1'); await import('url/to/module2') } }, { modules: 'module3', loader: async () => { await import('url/to/module3'); } } ] const dynamicLoader = new DynamicModuleLoader(loaders)
You can also register other loaders after init
dynamicLoader.register(['module4'], async () => { await import('url/to/module4') })
Load modules whenever in need (callbacks are module returns )
Return data should be considered by your async function
dynamicLoader.loadAll().then( callbacks => console.log(callbacks))
Load specific module as you wish
dynamicLoader.load(['module1','module2']).then(callbacks => console.log(callbacks ))