An IoC container for javascript
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
tests
.gitignore
README.md
gruntfile.js
include.js
index.js
package.json

README.md

scarlet-ioc

A plugin for doing IoC using Scarlet.

Installation

npm install scarlet-ioc

Quickstart

function MyObjectA(){
    var self = this;
    self.anyMethod = function(){
        console.log("calling A");
    };
}

function MyObjectB(myObjectA){
    var self = this;
    self.anyMethod = function(){
        myObjectA.anyMethod();
        console.log("calling B");
    };
}

var Scarlet = require("scarlet");
var scarlet = new Scarlet(["scarlet-ioc"]);

scarlet.plugins.ioc
    .register("myObjectA", MyObjectA)
    .register("myObjectB", MyObjectB);

var myObjectB = scarlet.plugins.ioc.resolve("myObjectB");
myObjectB.anyMethod();