This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default new ContainerModule(bind => { | |
bind(InterfaceA).to(ClassA); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@injectable() | |
export class ClassA implements InterfaceA { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new CollectionConsumer([{ foo(): void { console.log('Mock foo') }}]).doSth(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@injectable() | |
export class CollectionConsumer { | |
constructor( | |
@multiInject(InterfaceC) private setOfInterfaceC: InterfaceC[], | |
) { } | |
doSth() { | |
this.setOfInterfaceC.forEach(interfaceC => interfaceC.foo()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor( | |
@inject(MyClass) private myClass: MyClass | |
) { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inject('InterfaceB') private interfaceB: InterfaceB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const InterfaceA = Symbol('InterfaceA'); | |
export interface InterfaceA { | |
foo(): void; | |
} | |
export const InterfaceB = 'InterfaceB'; | |
export interface InterfaceB { | |
bar(): void; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@injectable() | |
export class SimpleConsumer { | |
@inject(InterfaceA) private interfaceA: InterfaceA; | |
constructor( | |
@inject(InterfaceB) private interfaceB: InterfaceB | |
) { } | |
doSth() { | |
this.interfaceA.foo(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bind(MenuContribution).to(ExampleMenuContribution); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@injectable() | |
export class ClassForInterfaceViaString implements InterfaceViaString { | |
do(): void { | |
console.log('Class Via String'); | |
} | |
} |