nintrajs
v0.0.10
Published
A dependency injection module based on intravenous
Downloads
5
Readme
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');
});