@mdzzohrabi/container
Dependency Injection Container
Last updated 3 years ago by mdzzohrabi .
MIT · Original npm · Tarball · package.json
$ cnpm install @mdzzohrabi/container 
SYNC missed versions from official npm registry.

Container

Usage

Simple usage :

let container = new Container
container.setParams({
    dbName: 'myDB'
})

container.set('connection', ($dbName) => {
    return $dbName;
})

container.get('connection'); // return "myDb"

Advanced :

let container = new Container({
    // Log service
    log: ($env) => {
        if ($env === 'dev') return (...params) => console.log(...params);
        return () => void;
    },
    // Database connection
    db: function dbConnection(log, $dbHost) {
        log(`Initialize connection`)
    }
}, { env: 'dev', dbHost: 'localhost' })

Current Tags

  • 1.0.1                                ...           latest (3 years ago)

2 Versions

  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 2
Dependencies (2)
Dev Dependencies (6)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |