Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

39 lines (28 sloc) 0.638 kB

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