Simple、Lightful、Efficient event library. only 966 bytes.
npm install yzk-eventful
import { Eventful } from 'yzk-eventful';
class A extends Eventful {
constructor() {
super();
this.test();
}
test() {
setInterval(() => {
// dispatchEvent
this.dispatchEvent('click', 1);
}, 3000);
}
}
const instance = new A();
let func = (event) => {
console.log(event);
};
// addEventListener
instance.addEventListener('click', func);
// hasEventListener
let exist = instance.hasEventListener('click', func);
// removeEventListener
let success = instance.removeEventListener('click', func);