0.0.5 • Published 7 years ago

function-events-extension v0.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Build Status

Function-events-extension

Extension for Function prototype to be able to handle events.

Example: https://plnkr.co/edit/vNpMhjjp9rxM8UN7majW

How to use

You can use npm i function-events-extension to install it as dependencie and in youre main file require('function-events-extension')

or

download built version build/Function.events.min.js and add it as normal script.

Add listener for event

function closeModalEventHandler(event) {
  document.querySelector('#modalWindow').css.display = 'none';
}

closeModalEventHandler.addEventListener('closeModalWindow')

Dispatch event

Standard event dispatch

Function.dispatch('closeModalWindow');

with custom arguments

Function.dispatch('closeModalWindow', 12, 'size');

Remove event listener

closeModalEventHandler.removeEventListener('closeModalWindow');

Event object

Each handler take one argument, eventObject. eventObject contain event name and custom arguments.

{
  "name": "eventName",
  "args": [arg1, arg2, ..., argN]
}
0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago