dependency injection made super easy - all you need | lazy register | with override | decorator support
yarn add inject.minimport { Inject } from 'inject.min';
class Example {
// your content
}
class Class {
@Inject(Example) prop!: Example;
constructor() {
// exists
console.log(this.prop);
}
}
const class1 = new Class();
const class2 = new Class();
// true
console.log(class1.prop === class2.prop);you need to have compiler option experimental decorators enabled in tsconfig.json
{
"compilerOptions": {
"experimentalDecorators": true
}
}MIT