Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Micro event emitter which provides the observer pattern to JavaScript object.
JavaScript HTML
Latest commit fcd9758 @mkuklis Merge pull request #23 from platogo/fix-unbind-with-undefined-callback
Do not remove event listener on unbind without callback


build status


asEvented is a micro event emitter which provides the observer pattern to JavaScript object. It works in the browser and server (node.js). The code follows a functional mixins pattern described by Angus Croll a-fresh-look-at-javascript-mixins.


In browser include single JavaScript file:

<script src="asevented.js"></script>

On server install asEvented via npm first:

npm install asEvented

and then include it in your project with:

var asEvented = require('asEvented');

Example Usage

Define the constructor which will make use of asEvented:

function Model() { = 0;

Add (mixin) asEvented functionality to Model with:;

model has now access to trigger, bind/on, one and unbind/off functions

Add some functions to Model:

Model.prototype.setId = function (id) { = id;
  this.trigger('change:id', id); // Model has now access to trigger

Create a new object and bind to change:id event:

var model = new Model();
model.bind('change:id', function (id) {
  console.log('id changed to: ' +  id);

Set a few model ids in order to trigger change:id event:


A single handler can be bound to multiple events by separating the events by spaces, though it will be ignorant of the triggering event:

model.bind('change:id change:pass', function() {
  console.log('Event called.');

And multiple events can be unbound in one call:

model.unbind('onload onready');



(The MIT License)

Copyright (c) 2015 Michal Kuklis

Something went wrong with that request. Please try again.