3 ms·
LucidJS: a lightweight, dependency-free event emitter library
- rstacruz 14y agoIf you are using jQuery and just need a simple generic event emitter, you may not need this library. var emitter = jQuery({}); emitter.on('ready', function() { alert("Ready!"); }); emitter.trigger('ready'); ...or if you're on Node, Node.js already has API for events: var EventEmitter = require('events').EventEmitter; var emitter = new EventEmitter(); emitter.on('ready', function() { alert("Ready!"); }); emitter.trigger('ready'); The reason you'd use LucidJS is for its other features that these solutions don't have, like `.set()` and `.pipe()`.
- godfreykfc 14y agoThe author did a talk at VanJS today, and he compared LucidJS with other events library[1]. From what I got out of it, besides the nice features it offers (set/pipe/etc), this is probably most useful for people who would like to release a library/JS API without depending on one of the "heavier" frameworks - for example, libraries like History.js would be able to use LucidJS as the events library instead of coupling with something like jQuery or rolling their own. [1]: http://lucidjs.harp.io/#slide-30 http://lucidjs.harp.io/#slide-30
- huskyr 14y agoFor those looking for more event libraries, try Stapes.js. As a bonus you'll also get class creation and MVC-like get/set with change events: http://hay.github.com/stapes/#m-mixinEvents http://hay.github.com/stapes/#m-mixinEvents Full disclosure: i'm the author :)
- smagch 14y agoIt might be nice to register on component(1) registry. https://github.com/component/component/wiki/Components https://github.com/component/component/wiki/Components
- borplk 14y agoCan someone give me a basic explanation/examples of the use cases of event emitters?
- binarymax 14y agoSince its not stated anywhere that I could see, and I wanted to see its 'lightweightness'...minified it is 8.9k and gzipped it is 2.3k