EventJS, a simple way to call events from functions

Recently I’ve been working heavily in javascript to build an application. I’ve learnt a hell of a lot about structuring an application and ideas on good design as well as patterns.

The Situation

When I started building the application, I wanted to be able to make it extensible. Everybody loves Extensible, don’t they? Well, I know I’m a fan of customisation. So I wanted to add the option that other developers could easily extend my application. Since I was using xulrunner as the environment, lucky me, I already have an addons library, BUT, that didn’t give me a way of adding functions to events, say when the program starts I wanted to alert “hello”, how would I do it?

The program had a startup function, but my event needed to fire after that ran. So I started thinking of writing a way to add events to functions, what i came out with, was EventJS.


EventJS is pretty simple in implementation. It has only four functions, these are:

Bind an event to a function
class, event, name, function
Unbind an event from a function
class, event, name
This fires the event, it’s to be used with in the function, eg. startup
class, event, [args]
This changes the function of the event
class, event, name, function

Get It?

You can get a copy of EventJS from my google code repository, aka here.


EventJS by Micheil aka Miksago is licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.


Feel free to write your opinion on usage and reason for using it or not as comments to this article.


    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s

%d bloggers like this: