@telemok/event-target-strict

0.0.7 • Public • Published

event-target-strict

Javascript ES6 EventTarget with .destroy() instead of .removeEventListener()

Features

  • Javascript ES6 EventTarget with .destroy() instead of .removeEventListener()

Examples:

  1. 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();
  }
}

Readme

Keywords

Package Sidebar

Install

npm i @telemok/event-target-strict

Weekly Downloads

2

Version

0.0.7

License

Apache-2.0

Unpacked Size

30.3 kB

Total Files

10

Last publish

Collaborators

  • telemok