update README

This commit is contained in:
Philipp Kunz 2017-05-13 10:33:34 +02:00
parent 3098fbec89
commit 7ab1a4eec7

View File

@ -2,14 +2,15 @@
simplifies lazy loading with TypeScript
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartsystem)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartsystem)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartsystem)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartsystem/)
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartsystem)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartsystem)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartsystem)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartsystem/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartsystem/badges/master/build.svg)](https://gitlab.com/pushrocks/smartsystem/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartsystem/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartsystem/commits/master)
[![build status](https://GitLab.com/pushrocks/smartsystem/badges/master/build.svg)](https://GitLab.com/pushrocks/smartsystem/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartsystem/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartsystem/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smartsystem.svg)](https://www.npmjs.com/package/smartsystem)
[![Dependency Status](https://david-dm.org/pushrocks/smartsystem.svg)](https://david-dm.org/pushrocks/smartsystem)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartsystem/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartsystem/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartsystem/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartsystem)
@ -25,26 +26,39 @@ smartsystem supports both npm and SystemJs as module loader.
```javascript
import { LazyModule } from 'smartsystem'
import * as _myPlugin from 'myPlugin' // plugin does not get loaded here at runtime
let myPluginLazy = new LazyModule<typeof _myPlugin>('myPlugin')
myPluginLazy.setLoader('npm') // sets the loader, defaults to npm anyway
// 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
let anotherPluginLazy = new LazyModule<typeof _anotherPlugin>('anotherPlugin')
// define lazy module
let anotherLazyModule = new LazyModule<typeof _anotherPlugin>('anotherPlugin', __dirname)
anotherPluginLazy.setLoader('systemjs') // sets the loader to systemjs
myPluginLazy.whenLoaded.then(myPlugin => {
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 */
})
myPluginLazy.load().then(myPlugin => {
myLazyModule.load().then(myPlugin => {
/* do something with myPlugin.
myPlugin receives the typings flow from LazyModule class
This DOES LOAD the module */
})
```
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)
For further information read the linked docs at the top of this README.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)