add event proxy

This commit is contained in:
Harvey Zack committed 2018-10-13 17:32:33 +08:00
1 parent 11bc295663
commit a395bc4550
7 files changed
+62 -76

No files matched your search

+9
View File
@@ -1,5 +1,14 @@
export default class Events {
constructor(art) {
this.art = art;
this.destroys = [];
this.proxy = this.proxy.bind(this);
}
proxy(target, name, callback) {
target.addEventListener(name, callback);
this.destroys.push(() => {
target.removeEventListener(name, callback);
});
}
}