jsLights
JavaScript module namespacer and event emitter
Usage
For apps using singletons which needs to be globally available but depending on other singletons inside application
For example displaying username after user had logged in:
function SayHello(username) {
console.log("Hello ", username);
}
class Welcome {
constructor() {
app.sayHello(app.user.username);
}
}
class User extends jsLights.EventEmitter {
constructor() {
this.login();
}
login() {
this.username = "johnDoe";
this.trigger("login");
}
}
Instantiate singleton
jsLights.instantiate('app.sayHello', SayHello);
jsLights.instantiate('app.user', User, 'app.sayHello');
jsLights.instantiate('app.welcome', Welcome, [
'onDocumentReady',
'app.sayHello',
'app.user->login'
]);
Building
For now, to be able to build minified file, you need to have "babel", "browserify" and "uglifyjs" installed globaly
(this should be changed in the near future)