node package manager

sire

Sire

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.

Build Status NPM version Dependency Status Bitdeli Badge

Install

With Node.js:

$ npm install sire

With Bower:

$ bower install shannonmoeller/sire

With Component:

$ component install shannonmoeller/sire

API for Sire Consumers

start( [obj...] ) : Sire

  • obj... Object (optional)

stop( [obj...] ) : Sire

  • obj... Object (optional)

use( [name], module ) : Sire

  • name String (optional)
  • module Object | Function

API for Sire Implementors

_start( module, [options] ) : instance

  • module Object | Function
  • options Object (optional)

Note: Implement this function, but do NOT call it directly.

_stop( [instance] )

  • instance Object (optional)

Note: Implement this function, but do NOT call it directly.

Example

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();

Test

$ npm test

Browser Support

License

MIT