diff options
author | sualko <klaus@jsxc.org> | 2021-12-31 02:16:14 +0300 |
---|---|---|
committer | sualko <klaus@jsxc.org> | 2021-12-31 02:16:14 +0300 |
commit | b49f4deae29a4a3e4c0a83c9a7733286ce10e1b5 (patch) | |
tree | bb8b4e919d38bd2562c988055cf84d9108f5bbf7 | |
parent | cc4fbb4a6a6da45ba802d128492306eeb66ff3f5 (diff) |
fix: type of hook repository
-rw-r--r-- | src/util/HookRepository.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/util/HookRepository.ts b/src/util/HookRepository.ts index e9415970..965a79d8 100644 --- a/src/util/HookRepository.ts +++ b/src/util/HookRepository.ts @@ -1,7 +1,7 @@ -export default class HookRepository<T extends Function> { +export default class HookRepository<Args extends any[] = any[]> { private hooks = {}; - public registerHook(eventName: string, func: T) { + public registerHook(eventName: string, func: (...args: Args) => void) { if (!this.hooks[eventName]) { this.hooks[eventName] = []; } @@ -9,7 +9,7 @@ export default class HookRepository<T extends Function> { this.hooks[eventName].push(func); } - public removeHook(eventName: string, func: T) { + public removeHook(eventName: string, func: (...args: Args) => void) { let eventNameList = this.hooks[eventName] || []; if (eventNameList.indexOf(func) > -1) { @@ -21,7 +21,7 @@ export default class HookRepository<T extends Function> { this.hooks[eventName] = eventNameList; } - public trigger(targetEventName: string, ...args) { + public trigger(targetEventName: string, ...args: Args) { let hooks = this.hooks; let eventNames = Object.keys(hooks); |