calvin-di

0.0.2 • Public • Published

Calvin

Calvin is a simple dependency injection container for JavaScript.

Example

const calvin = require(`calvin-di`);

const TestService = (US) => ({
    action: () => console.log(`action performed by ${US.getUserName()}.`)
});

const UserService = () => ({
    getUserName: () => "nathan"
});

const Startable = (TS) => ({
    start: () => {
        TS.action();
    }
});

const container = calvin();

container.register('TestService', TestService, {}, ['UserService']);
container.register('UserService', UserService);
container.register('Startable', Startable, {startable: true}, ['TestService']);

container.startAll();

Details

This is currently a pre-release library. Documentation and test suite forthcoming.

This was modeled after redradix/kontainer, but written from scratch with a few added featuers and slightly more complete error handling. Give that original library some love if you like what you see here.

Readme

Keywords

Package Sidebar

Install

npm i calvin-di

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

10.7 kB

Total Files

3

Last publish

Collaborators

  • nathanfiscaletti