2017-07-31 15:17:31 +02:00
|
|
|
---
|
|
|
|
name: smartsystem
|
|
|
|
description: simplifies lazy loading with TypeScript
|
|
|
|
---
|
2019-08-22 01:05:21 +02:00
|
|
|
|
2017-05-13 11:16:39 +02:00
|
|
|
# smartsystem
|
2019-08-22 01:05:21 +02:00
|
|
|
|
2017-05-13 11:16:39 +02:00
|
|
|
simplifies lazy loading with TypeScript
|
|
|
|
|
|
|
|
## Availabililty
|
2019-08-22 01:05:21 +02:00
|
|
|
|
2017-05-13 11:16:39 +02:00
|
|
|
[](https://www.npmjs.com/package/smartsystem)
|
|
|
|
[](https://GitLab.com/pushrocks/smartsystem)
|
|
|
|
[](https://github.com/pushrocks/smartsystem)
|
|
|
|
[](https://pushrocks.gitlab.io/smartsystem/)
|
|
|
|
|
|
|
|
## Status for master
|
2019-08-22 01:05:21 +02:00
|
|
|
|
2017-05-13 11:16:39 +02:00
|
|
|
[](https://GitLab.com/pushrocks/smartsystem/commits/master)
|
|
|
|
[](https://GitLab.com/pushrocks/smartsystem/commits/master)
|
|
|
|
[](https://www.npmjs.com/package/smartsystem)
|
|
|
|
[](https://david-dm.org/pushrocks/smartsystem)
|
|
|
|
[](https://www.bithound.io/github/pushrocks/smartsystem/master/dependencies/npm)
|
|
|
|
[](https://www.bithound.io/github/pushrocks/smartsystem)
|
|
|
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
|
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
|
|
[](http://standardjs.com/)
|
|
|
|
|
|
|
|
## Usage
|
2019-08-22 01:05:21 +02:00
|
|
|
|
2017-05-13 11:16:39 +02:00
|
|
|
We recommend the use of TypeScript for best Intellisense
|
|
|
|
|
|
|
|
smartsystem supports both npm and SystemJs as module loader.
|
|
|
|
|
|
|
|
```javascript
|
2019-08-22 01:05:21 +02:00
|
|
|
import { LazyModule } from 'smartsystem';
|
2017-05-13 11:16:39 +02:00
|
|
|
|
|
|
|
// plugin does not get loaded here at runtime
|
2019-08-22 01:05:21 +02:00
|
|
|
import * as _myPlugin from 'myPlugin';
|
2017-05-13 11:16:39 +02:00
|
|
|
|
|
|
|
// define the lazy module
|
2019-08-22 01:05:21 +02:00
|
|
|
let myLazyModule = new LazyModule() < typeof _myPlugin > ('myPlugin', __dirname);
|
2017-05-13 11:16:39 +02:00
|
|
|
|
|
|
|
// another plugin
|
2019-08-22 01:05:21 +02:00
|
|
|
import * as _anotherPlugin from 'anotherPlugin'; // plugin does not get loaded here at runtime
|
2017-05-13 11:16:39 +02:00
|
|
|
|
|
|
|
// define lazy module
|
2019-08-22 01:05:21 +02:00
|
|
|
let anotherLazyModule = new LazyModule() < typeof _anotherPlugin > ('anotherPlugin', __dirname);
|
2017-05-13 11:16:39 +02:00
|
|
|
|
|
|
|
myLazyModule.whenLoaded.then(myPlugin => {
|
2019-08-22 01:05:21 +02:00
|
|
|
/* do something with myPlugin.
|
2017-05-13 11:16:39 +02:00
|
|
|
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 */
|
2019-08-22 01:05:21 +02:00
|
|
|
});
|
2017-05-13 11:16:39 +02:00
|
|
|
|
|
|
|
myLazyModule.load().then(myPlugin => {
|
2019-08-22 01:05:21 +02:00
|
|
|
/* do something with myPlugin.
|
2017-05-13 11:16:39 +02:00
|
|
|
myPlugin receives the typings flow from LazyModule class
|
|
|
|
This DOES LOAD the module */
|
2019-08-22 01:05:21 +02:00
|
|
|
});
|
2017-05-13 11:16:39 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
For further information read the linked docs at the top of this README.
|
|
|
|
|
|
|
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
2019-08-22 01:05:21 +02:00
|
|
|
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
2017-05-13 11:16:39 +02:00
|
|
|
|
|
|
|
[](https://push.rocks)
|