smartsystem/README.md
2016-10-06 19:28:00 +02:00

2.3 KiB

smartsystem

simplifies lazy loading with TypeScript

Availabililty

npm git git docs

Status for master

build status coverage report Dependency Status bitHound Dependencies bitHound Code TypeScript node JavaScript Style Guide

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