Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
An IoC container for javascript
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

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();
Something went wrong with that request. Please try again.