0.0.2 • Published 10 years ago
vnls-event v0.0.2
vnls-event
Cross platform Eventemitter. In Nodejs de Nodejs Eventemmiter is used, on the browser side a reverse engineered Eventemitter is used.
Install:
Nodejs:
On node nodejs
npm install vnls
npm install vnls-eventThen, somewhere at the top of your code
require('vnls');
require('vnls-event');There is no need to bind it to a var because var VNLS is made global to the nodejs process so it's behavior is exactly like in a browser environment. All-though this IS a kind of pollution on nodejs.
Browser
In a browser (you may also download the file first):
<script type="text/javascript" src="https://raw.githubusercontent.com/jorritd/vnls/master/lib/vnls.min.js"></script>
<script type="text/javascript" src="https://raw.githubusercontent.com/jorritd/vnls-event/master/lib/vnls-event.min.js"></script>Usage:
var emitter = VNLS.getObject('event','EventEmitter');
emitter.addListener("test_event",function(){
// Do something
});or:
var emitter = VNLS.getObject('event','EventEmitter');
emitter.on("test_event",function(a,b,c){
// Do something
emitter.removeAllListeners("test_event");
});
emitter.emit("test_event",'a','b','c');Dependencies:
Development:
- jasmine-node Testing
npm install jasmine-node - nodewatch Autotesting TDD
npm install nodewatch - uglify-js Building
npm install uglify-js - jake rake, make, ant substitute (Java-script all the way)
npm install -g jake
For jake these are the commands:
jake compress: build minified version in './lib/*'jake test: run the specsjake autotest: run the specs on a filechange for TDD
For testing in a browser environment just point your browser to 'specs/index.html'.
It should run the same specs as jake test does. (The tests cover both browser and server)