JavaScript module husbandry. Base class for modules, such as applications and controllers, that will be responsible for managing the lifecycle of other modules, such as models, views, or child controllers. How modules are started and stopped is determined by the implementing class via
_start
and_stop
methods.
With Node.js:
$ npm install sire
With Bower:
$ bower install shannonmoeller/sire
With Component:
$ component install shannonmoeller/sire
obj...
Object
(optional)
obj...
Object
(optional)
name
String
(optional)module
Object | Function
module
Object | Function
options
Object
(optional)
Note: Implement this function, but do NOT call it directly.
instance
Object
(optional)
Note: Implement this function, but do NOT call it directly.
var Sire = require('sire');
function Foo(options, parent) {
this.options = options || {};
this.parent = parent;
}
function Bar(options, parent) {
this.options = options || {};
this.parent = parent;
}
function App() {
Sire.call(this);
return this
.use(Foo)
.use(Bar)
.start();
}
App.prototype = Object.create(Sire.prototype);
App.prototype.constructor = App;
App.prototype._start = function(Module, options) {
// create instance
return new Module(options, this);
};
App.prototype._stop = function(instance) {
// destroy instance
};
var app = new App();
$ npm test
MIT