2.3 KiB
2.3 KiB
smartsystem
simplifies lazy loading with TypeScript
Availabililty
Status for master
Usage
We recommend the use of TypeScript for best Intellisense
import {LazyModule, loadNow } from 'smartsystem'
import * as myPluginType from 'myPlugin' // plugin does not get loaded here at runtime
let myPluginPromised = LazyModule<typeof myPlugin>('myPlugin')
import * as anotherPluginType from 'anotherPlugin' // plugin does not get loaded here at runtime
let anotherPluginPromised = LazyModule<typeof anotherPlugin>('anotherPlugin')
myPluginPromised.then(myPlugin => { /* do something with myPlugin */ })
myPlugin.also(anotherPluginPromised).then((m,a) => {}) // also takes multiple other plugins
loadNow.only('myPlugin') // loads myPlugin and resolved the lazy promise
loadNow.also('myPlugin') // loads myPlugin and any chained 'also' modules