Skip to content

My own DI implementation to better understand the IOC concept

Notifications You must be signed in to change notification settings

johnybaryah/simpleIoC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple IoC library for Typescript

Currently supports transient and singleton lifetimes.

Usage:

// init a new service collection
const services = new ServiceCollection();

// register services [eg: myService of type IService]
services.addTransient('myService', myServiceImpl, DependenciesByName[]);

// register another service that has dependency on previous service 
services.addTransient('myService2', myService2Impl, ['myService']);

// build container
const container = services.createContainer();

// retrieve registered services
const service = container.getService('myService') as IService;

service.doSomething();

Releases

No releases published

Packages

No packages published