Live data from Hacker News

LucidJS: a lightweight, dependency-free event emitter library

robertwhurst.github.com

1–7 of 7 posts

Re: LucidJS: a lightweight, dependency-free event emitter library

#2
If 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()`.

Re: LucidJS: a lightweight, dependency-free event emitter library

#4
post #2

If 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.trigg…

The 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