##// END OF EJS Templates
working on IoC configuration
working on IoC configuration

File last commit:

r114:475b8ce3e850 ioc ts support
r114:475b8ce3e850 ioc ts support
Show More
Box.ts
35 lines | 690 B | video/mp2t | TypeScriptLexer
import { services } from "../di/Annotations";
import { Bar } from "./Bar";
// declare required dependencies
const config = services<{
bar: Bar;
}>();
// export service descriptor
export const service = config.build<Box<Bar>>();
@service.consume(config.dependency("bar"))
export class Box<T> {
private _value: T | undefined;
constructor(value: T) {
this._value = value;
}
@service.inject("bar")
setValue(value: T) {
this._value = value;
}
setObj(value: object) {
}
getValue() {
if (this._value === undefined)
throw new Error("Trying to get a value from the empty box");
return this._value;
}
}