Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Event emmiter for everything.

tag: v0.0.2

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 TODO
Octocat-spinner-32 event_api_notes.md
Octocat-spinner-32 index.js
Octocat-spinner-32 package.json
Octocat-spinner-32 tap_testem.js
Octocat-spinner-32 testem.yml
Octocat-spinner-32 tests.html
Octocat-spinner-32 tests.js
README.md

Emmitt - Event Emitter for Everything

Emmitt is a small Javascript library that can emit events on any Javascript object. It works with

  1. Plain Javascript objects (POJOs)
  2. jQuery wraped DOM elements
  3. Backbone models or objects extended with Backbone.Events
  4. Raw DOM elements

Install

Install via NPM npm install emmitt; or bower bower install emmitt.

Usage

Simple example

var E = require('emmitt');

var obj = new SomeObject();
E.on(obj, 'refresh', function(data){
  console.log(obj, 'was refreshed with', data);
});

// then later on...
E.emit(obj, 'refresh', data);

If the object in question is a jQuery wrapped DOM element, a Backbone model, or a raw DOM element, event handling will delegate properly to their respective methods for event handling.

API

  • on(object, event, handler) - registers an event handler for a given event on an object.
  • off(object, event, [handler]) - unregisters an event handler. If handler is not provided, removes all event handlers for the given event. Aliased to removeListener.
  • emit(object, event, [...args]) - emits an event on an object with the given arguments. Aliased to trigger.
  • allOff(object) - remove all event handlers from an object. Aliased to clearAllListeners.

Support

  • Node
  • Standard compliant browsers
  • Non-standard IE 7 and up
Something went wrong with that request. Please try again.