summary refs log tree commit diff
path: root/src/util/plugin/Plugin.ts
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-13 08:54:50 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-09-04 10:48:54 +0200
commit87d6a6778c6d502df511b639375fa219ac8713c6 (patch)
tree5da20d24c2f7fd17036e7ce67c72a25ec6c7bc36 /src/util/plugin/Plugin.ts
parentfeat(plugins): event system (diff)
downloadserver-87d6a6778c6d502df511b639375fa219ac8713c6.tar.xz
Update plugin loading, update example plugin, add ci task for testing if builds work
Diffstat (limited to '')
-rw-r--r--src/util/plugin/Plugin.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/util/plugin/Plugin.ts b/src/util/plugin/Plugin.ts

index 96e05843..1c86a006 100644 --- a/src/util/plugin/Plugin.ts +++ b/src/util/plugin/Plugin.ts
@@ -6,7 +6,14 @@ type PluginEvents = { loaded: () => void; }; -export class Plugin extends (EventEmitter as new () => TypedEventEmitter<PluginEvents>) { +//this doesnt work, check later: + //(EventEmitter as new () => TypedEventEmitter<PluginEvents>) { +export class Plugin extends EventEmitter { + private _untypedOn = this.on + private _untypedEmit = this.emit + public on = <K extends keyof PluginEvents>(event: K, listener: PluginEvents[K]): this => this._untypedOn(event, listener) + public emit = <K extends keyof PluginEvents>(event: K, ...args: Parameters<PluginEvents[K]>): boolean => this._untypedEmit(event, ...args) + async init() { // insert default config into database? }