@superherocheesecake/event-dispatcher

1.1.4 • Public • Published

EventDispatcher

Global EventDispatcher

NPM installation

npm i --save @superherocheesecake/event-dispatcher

Common practice

Most likely you will extend your own class.

import EventDispatcher from '@superherocheesecake/event-dispatcher';

class Module extends EventDispatcher {
    // ...
}

Methods

dispatchEvent(type, payload)

Payload can be any type of value.

this.dispatchEvent('eventName', {key: value});

addEventListener(type, listener)

this.addEventListener('eventName', listener);

addEventListenerOnce(type, listener)

this.addEventListenerOnce('eventName', listener);

removeEventListener(type, listener)

this.removeEventListener('eventName', listener);

hasEventListener(type, listener)

this.hasEventListener('eventName', listener);

Readme

Keywords

none

Package Sidebar

Install

npm i @superherocheesecake/event-dispatcher

Weekly Downloads

4

Version

1.1.4

License

none

Unpacked Size

9.86 kB

Total Files

12

Last publish

Collaborators

  • n0cha
  • edwardmediamonks
  • wesleysmulders
  • ksawery.mediamonks
  • vandenhork25
  • johanholwerda
  • renedrie
  • kristemmerman123
  • odin.schwartz
  • bolex222
  • coco_g
  • frontend_shcc
  • alfred_shcc
  • carinashcc
  • lukasfeitsma
  • jameswhite
  • raul.roman
  • jaak.kivinukk