Files
LingChair/server/api/BaseApi.ts
2025-09-06 01:53:09 +08:00

16 lines
561 B
TypeScript

import EventCallbackFunction from "../types/EventCallbackFunction.ts"
import ApiManager from "./ApiManager.ts"
import { CallMethod } from './ApiDeclare.ts'
export default abstract class BaseApi {
abstract getName(): string
constructor() {
this.onInit()
}
abstract onInit(): void
registerEvent(name: CallMethod, func: EventCallbackFunction) {
if (!name.startsWith(this.getName() + ".")) throw Error("注冊的事件應該與接口集合命名空間相匹配: " + name)
ApiManager.addEventListener(name, func)
}
}