Socket
Book a DemoInstallSign in
Socket

eventer-js

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eventer-js

Utility for easy events handling

0.1.9
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

eventer

Utility for easy events handling

Installing

You can easily install it as a dependency for your project with npm

npm install eventer-js

Using it

Add event listener

First you'll need to import and then create an Eventer main object, you can pass true to the constructor to tell eventer that you want him to extend the default HTMLElement prototype, this is under param to avoid unwanted behaviour and conflicts with other libraries or tools.

	import {Eventer} from './lib/Eventer/eventer-js';
	var eventer = new Eventer(true);

Then you can access all the four methods exposed by Eventer objects. To bind an event you simply need to call bindEvent this way

	eventer.bindEvent( eventName, DOMElement, eventFunction, useCapture  );

where eventName is the event name to listen to, DOMElement is the non-live DOM instance of the element (usualy retrived with querySelector) and eventFunction is the callback function to trigger when the event is fired, you can also set useCapture as you do in vanilla js. You can also use the on shorthand with the same parameters

Plus, if you have passed true to the constructor you are able to use the eventerOn method directly on the HTMLElement.

	document.querySelector('.bottone').on('click', function() {
		// Your awesome code here...
	}, true);

Remove event listener

If you need to remove event you can use one of these methods

	eventer.unbindEvent( eventName, DOMElement, eventFunction );
	eventer.unbindAll( eventName, DOMElement );
	eventer.clearAll( DOMElement );

or you may rather use the off event, witch is a shorthand for the above three methods, it will handle their call depending on the params type and number

	eventer.off( eventName, DOMElement, eventFunction );
	// or
	eventer.off( eventName, DOMElement );

FAQs

Package last updated on 01 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.