TypeScript Injections

Dependency injection library, which move responsibility from producer to customer.

TypeScript Injections is a one of many variations about implementation of Inversion of Control (IoC). Main features are: 1. Support for popular libraries and frameworks (e.g. Vue.js) Many libraries, which implements IoC requires classes to work and resolving dependency can be do only in constructor params, but many libraries and frameworks (e.g. Vue.js) operand on object "non-class", and we don't have access to the constructor. For this reason some libraries, which implements IoC are useless, because they can not be used with popular frameworks and libraries. 2. This library supports object "non-class" and resolving dependency can be do anywhere and this feature resolving previously mentioned trouble. 3. Partial support for Dependency Injection Principle (DIP) Because of how TypeScript works, there is not exists technical possibility to full implementation of DIP, because interfaces not exists at the runtime, but they are the basis of DIP. For this reason all libraries of this type must compromise, when want to supports DIP. In this library these compromise is using abstract class instead interfaces. More about this you can read in Partial support for Dependency Injection Principle (DIP) section. 4. Responsibility for resolving dependency is moved from producer to customer. Many libraries uses for dependency injections work in such a way that the class decide that can be resolving by dependency (generally via @injectable decorator). In my opinion, that implementation is a broken of DIP rule and in this library i moved thar responsibility into customer using Resolve method. a) Singleton is transparent. Management of singleton is moved into definition and that has 2 important benefits: b) Singleton is transparent - customer doesn't know he use singleton - he use object same as using object which is not singleton Management of instances is moved into library and thus classes no longer needs manage of own instance - single-responsibility principle (SRP) rule is kept.