o-system

2.0.45 • Public • Published

Install

npm install --save o-system

Use it

var service = require('o-system').Service;

class AppCode{
    constructor(){
        this.id = Math.random();
    }
}

class TestA{
    constructor(){
        this.id = Math.random();
    }
}

class TestB {
    constructor(testa,appCode){
        this.id = Math.random();
        this.testa = testa;
        this.appCode = appCode;
    }
}


class TestC {
    constructor(testb,testa){
        this.id = Math.random();
        this.testa = testa;
        this.testb = testb;
    }
}

  const container = service.createContainer();

    container.add('test.a',TestA)
                 .transient();
    container.add('app.code',AppCode)
                 .scoped();

    container.add('test.b',TestB)
                .args('test.a','app.code');
    container.add('test.c',TestC)
                 .args('test.b','test.a')
                 .scoped();

    var provider = container.build();
    let testc = provider.get('test.c');
    let testa = provider.get('test.a');
    assert.equal(testc.testa.id,testc.testb.testa.id); // true
    assert.notEqual(testa.id,testc.testa.id); // true

Package Sidebar

Install

npm i o-system

Weekly Downloads

4

Version

2.0.45

License

ISC

Unpacked Size

107 kB

Total Files

41

Last publish

Collaborators

  • yubitech