@uxland/ioc
v1.0.4
Published
IOC
Downloads
183
Readme
UXL IOC
| Build Status | Statements | Branches | Functions | Lines | | ----------------------------------------------- | --------------------------------------------- | ----------------------------------------- | ------------------------------------------- | ----------------------------------- | | | | | | |
Installation
npm i @uxland/ioc
Usage
Register constructor singleton to iocContainer
Registers a constructor singleton to the InversionOfControl container. Each time a reference of the constructor or abstract class is provided with inversify, the container will provide with its singleton pair.
@provideSingleton()
class IOCAdapter {
method(): void {
console.log("Calling `method` from `IOCAdapter`");
}
}
class Adapter {
constructor(@inject(IOCAdapter) protected adapter: IOCAdapter) {
this.adapter.method(); // => 'Calling `method` from `IOCAdapter`'
}
}
Set Mediator resolver
This method overrides the mediator default resolver to use our own container.
const container: Container = new Container();
setMediatorResolver(container);