client/events: add experimental EventTarget
This commit is contained in:
parent
892c154b34
commit
e93af8b577
1 changed files with 14 additions and 0 deletions
|
@ -36,6 +36,19 @@ function notify(messageClass, message) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class EventTarget {
|
||||||
|
constructor() {
|
||||||
|
this.eventTarget = document.createDocumentFragment();
|
||||||
|
for (let method of [
|
||||||
|
'addEventListener',
|
||||||
|
'dispatchEvent',
|
||||||
|
'removeEventListener'
|
||||||
|
]) {
|
||||||
|
this[method] = this.eventTarget[method].bind(this.eventTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Success: 'success',
|
Success: 'success',
|
||||||
Error: 'error',
|
Error: 'error',
|
||||||
|
@ -47,4 +60,5 @@ module.exports = {
|
||||||
notify: notify,
|
notify: notify,
|
||||||
listen: listen,
|
listen: listen,
|
||||||
unlisten: unlisten,
|
unlisten: unlisten,
|
||||||
|
EventTarget: EventTarget,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue