breadboard

A lightweight IoC Container for node

Breadboard

A lightweight IoC Container for node.

In electronics, a breadboard is a construction base for fast prototyping. You just plug components on it, and connects them to each other. This is what I wanted to reproduce, a simple IoC container so.

## Quick start

First, install the module :

npm install breadboard

Then, you can start using it :

var Breadboard = require("./lib"),
    Component = Breadboard.Component,
    bb = new Breadboard();
 
bb.add('foo', Component.new({
    methodfunction() {
        return 'Hello world !'
    }
}));
 
bb.add('bar', Component.new(['foo'], {
    useFoofunction() {
        return this.foo.method();
    }
}).on('dependencies:loaded', function(dependencies) {
    this.foo = dependencies['foo'];
}));
 
bb.load();
 
bb.has('bar'); // => true 
 
var bar = bb.get('bar');
bar.useFoo(); // => 'Hello world !'