2018-07-23 11:44:34 +00:00
|
|
|
export default function hooks() {
|
2018-07-23 11:12:06 +00:00
|
|
|
this._hooks = {};
|
2018-07-23 11:44:34 +00:00
|
|
|
this.all = ["preRenderSvg", "postRenderSvg", "insertText"];
|
2018-07-23 20:14:32 +02:00
|
|
|
}
|
2018-07-23 11:12:06 +00:00
|
|
|
|
2018-07-23 20:14:32 +02:00
|
|
|
hooks.prototype.list = function(hook) {
|
|
|
|
if (typeof this._hooks[hook] === "undefined") {
|
|
|
|
return false;
|
|
|
|
}
|
2018-07-23 11:12:06 +00:00
|
|
|
|
2018-07-23 20:14:32 +02:00
|
|
|
return this._hooks[hook];
|
|
|
|
};
|
2018-07-23 11:12:06 +00:00
|
|
|
|
2018-07-23 20:14:32 +02:00
|
|
|
hooks.prototype.attach = function(hook, obj) {
|
|
|
|
if (typeof this._hooks[hook] === "undefined") return;
|
|
|
|
for (let func of this._hooks[hook]) {
|
|
|
|
obj.pre(hook, func);
|
|
|
|
}
|
|
|
|
};
|