1
0
Fork 0
freesewing/src/hooks.js

20 lines
439 B
JavaScript
Raw Normal View History

export default function hooks() {
2018-07-23 11:12:06 +00:00
this._hooks = {};
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);
}
};