0.0.2 • Published 2 years ago

calvin-di v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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.