nintrajs

0.0.10 • Public • Published

nintrajs

Nintrajs is a dependency injection and dependency resolver framework based on the intravenous framework written by Roy Jacobs.

create a module

import {Module, Types} from 'nintrajs'
import MyService from '../MyService'

class StandardInjectionModule extends Module {

    constructor() {
        super();
    }

    initialize() {
        this._registerServices();
    }

    getBindings(){
        return super.getBindings();
    }

    _registerServices() {
        this._addBinding('MyService', MyService, Types.Singleton);
    }

    _addBinding(name,type,bindingType) {
        return super._addBinding(name,type,bindingType);
    }
}

export default StandardInjectionModule;

use the dependency resolver

import {DependencyResolver} from 'nintrajs'
import StandardInjectionModule from './injection/StandardInjectionModule'

let standardModule = new StandardInjectionModule();
DependencyResolver.initialize(standardModule)
    .then(() => {
        let myService = DependencyResolver.get('MyService');
    });

Readme

Keywords

Package Sidebar

Install

npm i nintrajs

Weekly Downloads

0

Version

0.0.10

License

MIT

Last publish

Collaborators

  • nhutier