aisle
v1.0.1
Published
Module for global event handling and namespacing.
Maintainers
Readme
aisle
Module for global event handling and namespacing.
$ npm install aisleUsage
Programmatically
var aisle = require("aisle");Call your aisle for namespaces or use it as you would an EventEmitter object.
Namespaces
If you call aisle without any arguments, then aisle will tap into and return require.main.exports, otherwise aisle will return your namespace and its data. If you provide data with your namespace, then aisle will assign that data to your namespace (namespaces will be created or overwritten.)
// main.js
var aisle = require("aisle");
module.exports = {"data": "main"};
aisle("my-namespace",{"abc": 123});
require("./other");// other.js
var aisle = require("aisle");
console.log(aisle()); // { data: 'main' }
console.log(aisle("my-namespace")); // { abc: 123 }
console.log(aisle("nonexistent-namespace")); // undefinedEvents
With your Node's version, use Node's documentation to find its EventEmitter abilities.
// main.js
var aisle = require("aisle");
aisle.on("some global event",console.log); // { data: [ 'here', true ] }
require("./other");// other.js
var aisle = require("aisle");
aisle.emit("some global event",{"data": ["here",true]});