A TypeScript library for interacting with the system it's running on, including environment, network, and hardware information.
Go to file
2017-05-13 11:16:39 +02:00
dist update tests and README 2017-05-13 11:03:24 +02:00
docs add docs 2017-05-13 11:16:39 +02:00
test update tests and README 2017-05-13 11:03:24 +02:00
ts update to latest standards 2016-12-10 19:46:47 +01:00
.gitignore update 2016-10-06 23:00:29 +02:00
.gitlab-ci.yml update ci 2017-05-13 10:34:08 +02:00
npmextra.json update npmextra.json 2016-12-10 22:15:22 +01:00
package.json 1.0.16 2017-05-13 11:03:40 +02:00
README.md update README 2017-05-13 10:33:34 +02:00
tslint.json add basic module structure 2016-10-12 01:41:30 +02:00
yarn.lock update tests and README 2017-05-13 11:03:24 +02:00

smartsystem

simplifies lazy loading with TypeScript

Availabililty

npm git git docs

Status for master

build status coverage report npm downloads per month Dependency Status bitHound Dependencies bitHound Code TypeScript node JavaScript Style Guide

Usage

We recommend the use of TypeScript for best Intellisense

smartsystem supports both npm and SystemJs as module loader.

import { LazyModule } from 'smartsystem'

// plugin does not get loaded here at runtime
import * as _myPlugin from 'myPlugin'

// define the lazy module
let myLazyModule = new LazyModule<typeof _myPlugin>('myPlugin', __dirname)

// set the loader, defaults to npm anyway, can be systemjs alternatively
myLazyModule.setLoader('npm') 

// another plugin
import * as _anotherPlugin from 'anotherPlugin' // plugin does not get loaded here at runtime

// define lazy module
let anotherLazyModule = new LazyModule<typeof _anotherPlugin>('anotherPlugin', __dirname)
anotherPluginLazy.setLoader('systemjs') // sets the loader to systemjs

myLazyModule.whenLoaded.then(myPlugin => {
    /* do something with myPlugin. 
       myPlugin receives the typings flow from LazyModule class
       This does NOT load the module during runtime
       The promise whenLoaded will be resolved whenever load() is called for the first time */
})

myLazyModule.load().then(myPlugin => {
    /* do something with myPlugin. 
       myPlugin receives the typings flow from LazyModule class
       This DOES LOAD the module */
})

For further information read the linked docs at the top of this README.

MIT licensed | © Lossless GmbH | By using this npm module you agree to our privacy policy

repo-footer