Custom events system in JavaScript – LightEvents.js

Share on Facebook1Share on Reddit0Tweet about this on TwitterShare on Google+0

Needing an event subscription and publishing system for a HTML5/canvas game I’m creating, I wrote a very light event system.

Anything than can call JavaScript (link, button, etc) can raise an event:

LightEvents.publishEvent('event name', data);

Subscribing to events is equally easy:

Here is the LightEvents object, demo is embedded below

JS Bin

Share on Facebook1Share on Reddit0Tweet about this on TwitterShare on Google+0