mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
feat: wrap NT-Event
This commit is contained in:
parent
21b6928ca6
commit
700f308d6e
33
src/common/utils/EventTask.ts
Normal file
33
src/common/utils/EventTask.ts
Normal file
@ -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 }) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user