@null-studios/universal-ioc
v2.0.0
Published
Simple TypeScript IoC container.
Downloads
1
Readme
universal-ioc
Simple TypeScript IoC container.
yarn add @null-studios/universal-ioc
Usage
import { IocContainer } from '@null-studios/universal-ioc';
class Application {
public static inject = [
'configuration',
] as const;
constructor(
configuration: Configuration,
) {
// ...
}
}
const container = new IocContainer().register([
{
type: 'value',
name: 'configuration',
value: {
width: 300,
height: 300,
frameRate: 120,
},
},
{
type: 'class',
name: 'application',
constructor: Application,
lifetime: 'singleton',
},
]);
const application = container.resolve('application') as Application;
application.start();