https://github.com/opentmi/opentmi-addon
Opentmi Addon class
https://github.com/opentmi/opentmi-addon
opentmi
Last synced: 3 months ago
JSON representation
Opentmi Addon class
- Host: GitHub
- URL: https://github.com/opentmi/opentmi-addon
- Owner: OpenTMI
- License: mit
- Created: 2018-01-27T10:47:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-15T20:39:57.000Z (about 1 year ago)
- Last Synced: 2025-02-08T13:25:43.022Z (3 months ago)
- Topics: opentmi
- Language: JavaScript
- Size: 92.8 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenTMI addon base class
This module contains base class and utils for OpenTMI addons.
## API
### `Addon`
This is base class which stores some basic things, like logger instance, eventBus etc.
**getters**
* `this.logger` to get logger instance
* `this.eventBus` to get opentmi eventBus instance
* `this.app` to get opentmi express application instance
* `this.server` to get express server instance
* `this.io` to get socket.io instanceUsage example:
```
const {Addon} = require('opentmi-addon');class MyAddon extends Addon {
constructor(...data) {
super(...data);
this.logger.info('MyAddon constructor');
}
}
module.exports = MyAddon;
```### `singleton()`
singleton mixer can be used to create addon which manage some
background operations like analyse results. Those background operations
is activated when `register` -function is called.
Note that `register` is called only once even opentmi is started ìn cluster mode.**getters**
* `isRegistered` is true for instance which contains singleton instanceUsage example:
```
const {Addon, singleton} = require('opentmi-addon');
class MyAddon extends Addon {
constructor(...data) {
super(...data);
this.logger.info('MyAddon constructor');
}
}
const MySingletonAddon = singleton(MyAddon);
module.exports = MySingletonAddon;
```