You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ComponentB.ts 698B

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. }