0.9.0 • Published 10 years ago

mods v0.9.0

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
10 years ago

mods

mods is an evented module system for Node.js. Put simply, you throw a bunch of Node.js modules into your mods instance and they can fire events to each other and call each others' methods. Events can be fired globally or to a single target.

Usage

Installation

$ npm install mods

Example

index.js
var mods = new(require('mods'))
mods.load(require('./hello'))
mods.load('bye')

var result = mods.fire('$test')
console.log(result)
hello.js
exports.name = 'hello'
exports.$test = function()
{
	console.log('hello --> $test')

	// this will fire `hello$test` which is not hooked so nothing will happen
	this.mods.fire('test')

	return 'result from hello.js'
}
bye.js
exports.name = 'bye'
exports.$test = function()
{
	console.log('bye --> $test')

	// this will fire `bye$test` which is hooked so it will be called
	return this.mods.fire('test')
}

exports.bye$test = function()
{
	console.log('bye --> bye$test')
	return 'result from bye$test in bye.js'
}
Output
$ node index
hello -> $test
bye --> $test
bye --> bye$test
0.9.0

10 years ago

0.8.1

10 years ago

0.8.0

10 years ago

0.7.1

10 years ago

0.7.0

10 years ago

0.6.2

10 years ago

0.6.1

10 years ago

0.6.0

10 years ago

0.5.0

10 years ago

0.4.3

10 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.4.0

11 years ago

0.3.1

11 years ago

0.3.0

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago