Standalone, powerful dependency injector for TypeScript and Javascript
Standalone, powerful dependency injector for TypeScript and Javascript
EcmaScript 5 or higer and Typescript 1.5 beta or higer
All you need are several annotation
module Typejector.Sample {
import resolve = Annotation.resolve;
import inject = Annotation.inject;
import injection = Annotation.injection;
@injection
class SingletonClass {
public cat: string = "Kitty";
public dog: string = "Hot";
public say() {
alert(`${this.cat}-Cat and ${this.dog}-Dog`);
}
}
@injection
class SimpleClass {
public say(something: string) {
alert(`You said ${something}?`);
}
}
@resolve
class NeedInjectionsClass {
@inject(SingletonClass)
public helper: SingletonClass;
@inject(SimpleClass)
public simpleHelper: SimpleClass;
constructor() {
this.helper.say();
this.simpleHelper.say("wow");
}
}
class ChildClass extends NeedInjectionsClass {
}
var needInjection = new ChildClass();
}
@injection
class someClass {
}
@injection(false)
class someClazz {
}