@telemok/event-target-strict
v0.0.7
Published
Javascript ES6 EventTarget with .destroy() instead of .removeEventListener()
Downloads
2
Readme
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();
}
}