event-target-strict
Javascript ES6 EventTarget with .destroy() instead of .removeEventListener()
Features
- Javascript ES6 EventTarget with .destroy() instead of .removeEventListener()
Examples:
- Parsing students database
import { EventTargetStrict } from "@telemok/event-target-strict"
class Test extends EventTargetStrict
{
dispatch()
{
this.dispathEvent(new Event('example'));
}
}
class Component extends ***
{
constructor()
{
super();
this.test = new Test();
}
componentDidMount()
{
this.listener1 = this.test.addEventListener('example',(event)=>{
console.log("example-listener1");
});
this.listener2 = this.test.addEventListener('example',(event)=>{
console.log("example-listener2");
});
}
componentWillUnmount()
{
this.listener1.delete();
this.listener2.delete();
}
}