您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132
  1. import { Inject, Singleton } from "../../src/Decorator"
  2. import { Initializable } from "../../src/Interfaces"
  3. import { COMPONENT_B_VALUE } from "../CONSTANTS"
  4. import { ComponentA } from "./ComponentA"
  5. export abstract class IComponentB{
  6. getFromA: () => string
  7. getFromThis: () => string
  8. }
  9. @Singleton({
  10. interface: IComponentB,
  11. })
  12. export class ComponentB implements IComponentB, Initializable{
  13. @Inject(ComponentA)
  14. private componentA: ComponentA
  15. private value: string
  16. getFromA(): string {
  17. return this.componentA.getFromThis()
  18. }
  19. getFromThis(): string {
  20. return this.value
  21. }
  22. initialize(): void{
  23. this.value = COMPONENT_B_VALUE
  24. }
  25. }