Skip to content

Latest commit

 

History

History
11 lines (11 loc) · 522 Bytes

value_injection.md

File metadata and controls

11 lines (11 loc) · 522 Bytes

Injecting a constant or dynamic value

Binds an abstraction to a constant value:

container.bind<Katana>("Katana").toConstantValue(new Katana());

Binds an abstraction to a dynamic value:

container.bind<Katana>("Katana").toDynamicValue((context: interfaces.Context) => { return new Katana(); });
// a dynamic value can return a promise that will resolve to the value
container.bind<Katana>("Katana").toDynamicValue((context: interfaces.Context) => { return Promise.resolve(new Katana()); });