mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-19 11:21:20 -08:00
17 lines
444 B
JavaScript
17 lines
444 B
JavaScript
export default class EventProxy {
|
|
constructor() {
|
|
this.destroyEvents = [];
|
|
this.proxy = this.proxy.bind(this);
|
|
}
|
|
|
|
proxy(target, name, callback, option = {}) {
|
|
target.addEventListener(name, callback, option);
|
|
this.destroyEvents.push(() => {
|
|
target.removeEventListener(name, callback, option);
|
|
});
|
|
}
|
|
|
|
destroy() {
|
|
this.destroyEvents.forEach(event => event());
|
|
}
|
|
} |