2018-07-17 14:16:17 +00:00
|
|
|
export class Hooks {
|
2018-07-18 11:45:46 +00:00
|
|
|
hooks: object;
|
|
|
|
all: string[];
|
2018-07-17 14:16:17 +00:00
|
|
|
|
|
|
|
constructor(app) {
|
|
|
|
this._hooks = {};
|
2018-07-18 11:45:46 +00:00
|
|
|
this.all = ['preRenderSvg', 'postRenderSvg'];
|
2018-07-17 14:16:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
list(hook): function[] {
|
|
|
|
if(typeof this._hooks[hook] === 'undefined') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this._hooks[hook];
|
|
|
|
}
|
|
|
|
|
|
|
|
attach (hook: string, obj: object): void {
|
|
|
|
if(typeof this._hooks[hook] === 'undefined') return;
|
|
|
|
for(let func of this._hooks[hook]) {
|
|
|
|
obj.pre(hook, func);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|