fix(core): update
This commit is contained in:
@ -2,16 +2,20 @@
|
||||
name: smartsystem
|
||||
description: simplifies lazy loading with TypeScript
|
||||
---
|
||||
|
||||
# smartsystem
|
||||
|
||||
simplifies lazy loading with TypeScript
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/smartsystem)
|
||||
[](https://GitLab.com/pushrocks/smartsystem)
|
||||
[](https://github.com/pushrocks/smartsystem)
|
||||
[](https://pushrocks.gitlab.io/smartsystem/)
|
||||
|
||||
## Status for master
|
||||
|
||||
[](https://GitLab.com/pushrocks/smartsystem/commits/master)
|
||||
[](https://GitLab.com/pushrocks/smartsystem/commits/master)
|
||||
[](https://www.npmjs.com/package/smartsystem)
|
||||
@ -23,42 +27,43 @@ simplifies lazy loading with TypeScript
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
|
||||
We recommend the use of TypeScript for best Intellisense
|
||||
|
||||
smartsystem supports both npm and SystemJs as module loader.
|
||||
|
||||
```javascript
|
||||
import { LazyModule } from 'smartsystem'
|
||||
import { LazyModule } from 'smartsystem';
|
||||
|
||||
// plugin does not get loaded here at runtime
|
||||
import * as _myPlugin from 'myPlugin'
|
||||
import * as _myPlugin from 'myPlugin';
|
||||
|
||||
// define the lazy module
|
||||
let myLazyModule = new LazyModule<typeof _myPlugin>('myPlugin', __dirname)
|
||||
let myLazyModule = new LazyModule() < typeof _myPlugin > ('myPlugin', __dirname);
|
||||
|
||||
// another plugin
|
||||
import * as _anotherPlugin from 'anotherPlugin' // plugin does not get loaded here at runtime
|
||||
import * as _anotherPlugin from 'anotherPlugin'; // plugin does not get loaded here at runtime
|
||||
|
||||
// define lazy module
|
||||
let anotherLazyModule = new LazyModule<typeof _anotherPlugin>('anotherPlugin', __dirname)
|
||||
let anotherLazyModule = new LazyModule() < typeof _anotherPlugin > ('anotherPlugin', __dirname);
|
||||
|
||||
myLazyModule.whenLoaded.then(myPlugin => {
|
||||
/* do something with 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.
|
||||
/* 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](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[](https://push.rocks)
|
||||
|
Reference in New Issue
Block a user