feat: wrap NT-Event
This commit is contained in:
1 parent
d167f339c8
commit
854f0884dc
1 file changed
+33
@@ -0,0 +1,33 @@
|
||||
import { randomUUID } from "crypto";
|
||||
export interface NTEventType {
|
||||
EventName: string,
|
||||
EventFunction: Function,
|
||||
ListenerName: string,
|
||||
ListenerFunction: Function
|
||||
}
|
||||
export class NTEvent<T> {
|
||||
EventData: NTEventType;
|
||||
EventTask: Map<string, Function> = new Map<string, Function>();
|
||||
constructor(params: NTEventType) {
|
||||
params.ListenerFunction = this.DispatcherListener;
|
||||
this.EventData = params;
|
||||
}
|
||||
async DispatcherListener(...args: any[]) {
|
||||
for (let task of this.EventTask.values()) {
|
||||
if (task instanceof Promise) {
|
||||
await task(...args);
|
||||
}
|
||||
task(...args);
|
||||
}
|
||||
}
|
||||
async Call(params: T & { checker?: Function }) {
|
||||
|
||||
}
|
||||
async CallWaitTwice(params: T & { checker?: Function }) {
|
||||
|
||||
}
|
||||
async CallWaitVoid(param: T & { checker?: Function }) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user