mirror of
https://github.com/motajs/template.git
synced 2026-11-30 18:54:30 +08:00
fix: Hook 接口重复添加钩子的问题
This commit is contained in:
1 parent
b5eb79ecdc
commit
b571269036
1 file changed
+2
@@ -21,6 +21,8 @@ export abstract class Hookable<
|
||||
protected abstract createController(hook: Partial<H>): C;
|
||||
|
||||
addHook(hook: Partial<H>): C {
|
||||
const exist = this.hookMap.get(hook);
|
||||
if (exist) return exist.controller;
|
||||
const controller = this.createController(hook);
|
||||
const obj: IHookObject<H, C> = { hook, controller };
|
||||
this.hookMap.set(hook, obj);
|
||||
|
||||
Reference in new issue
Block a user