Box.ts
28 lines
| 532 B
| video/mp2t
|
TypeScriptLexer
|
|
r110 | import { config } from "./config"; | ||
|
|
r107 | |||
|
|
r111 | const service = config.build("barBox"); | ||
|
|
r107 | |||
|
|
r111 | @service.consume(config.dependency("bar")) | ||
|
|
r109 | export class Box<T> { | ||
| private _value: T | undefined; | ||||
|
|
r108 | |||
|
|
r109 | constructor(value: T) { | ||
| this._value = value; | ||||
| } | ||||
|
|
r107 | |||
|
|
r110 | @service.inject("bar") | ||
|
|
r107 | setValue(value: T) { | ||
| this._value = value; | ||||
| } | ||||
|
|
r109 | setObj(value: object) { | ||
| } | ||||
|
|
r107 | getValue() { | ||
|
|
r109 | if (this._value === undefined) | ||
| throw new Error("Trying to get a value from the empty box"); | ||||
|
|
r107 | return this._value; | ||
| } | ||||
|
|
r111 | } | ||
