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

File last commit:

r127:850cc60b6e2a ioc ts support
r128:882b53b2ba5b ioc ts support
Show More
Box.ts
29 lines | 724 B | video/mp2t | TypeScriptLexer
import { Bar } from "./Bar";
import { annotate, dependency } from "./services";
// export service descriptor
// через service передается информация о типе зависимости
// даже если это шаблон.
export const service = annotate<Box<Bar>>();
@service.wire()
export class Box<T> {
private _value: T | undefined;
constructor(value?: T) {
this._value = value;
}
@service.inject(dependency("bar"))
setValue(value: T) {
this._value = value;
return value;
}
getValue() {
if (this._value === undefined)
throw new Error("Trying to get a value from the empty box");
return this._value;
}
}