scarlet-ioc

2.0.3 • Public • Published

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

Package Sidebar

Install

npm i scarlet-ioc

Weekly Downloads

3

Version

2.0.3

License

MIT

Last publish

Collaborators

  • fir3pho3nixx