Skip to content

Latest commit

 

History

History
35 lines (22 loc) · 614 Bytes

README.md

File metadata and controls

35 lines (22 loc) · 614 Bytes

@fab1o/ioc

IoC container for TypeScript.

Usage

import { Container } from '@fab1o/ioc';

const container = new Container();

interface Ball {}
class Volleyball implements Ball {}

container.register<Ball>('ball', Volleyball);

const ball = container.get<Ball>('ball');
const ball2 = container.get<Ball>('ball');

ball === ball2; // false

Singleton

interface Ball {}
class Volleyball implements Ball {}

container.register<Ball>('ball', Volleyball, { singleton: true });

const ball = container.get<Ball>('ball');
const ball2 = container.get<Ball>('ball');

ball === ball2; // true