All Projects → typestack → Typedi

typestack / Typedi

Licence: mit
Simple yet powerful dependency injection tool for JavaScript and TypeScript.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Typedi

Qframework
Unity3D System Design Architecture
Stars: ✭ 2,326 (-17.87%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
ThunderboltIoc
One of the very first IoC frameworks for .Net that has no reflection. An IoC that casts its services before thunder casts its bolts.
Stars: ✭ 40 (-98.59%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
vesselize
⛵ A JavaScript IoC container that works seamlessly with Vue.js and React.
Stars: ✭ 22 (-99.22%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
Container Ioc
Inversion of Control container & Dependency Injection for Javascript and Node.js apps powered by Typescript.
Stars: ✭ 89 (-96.86%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
Kangaru
🦘 A dependency injection container for C++11, C++14 and later
Stars: ✭ 297 (-89.51%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
waiter
Dependency injection, Inversion of control container for rust with compile time binding.
Stars: ✭ 71 (-97.49%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
React Ioc
Hierarchical Dependency Injection with new React 16 Context API
Stars: ✭ 133 (-95.3%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
vue-ioc
IoC and DI for Vue powered by InversifyJS and inspired by Angular Module syntactic sugar.
Stars: ✭ 39 (-98.62%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
granitic
Web/micro-services and IoC framework for Golang developers
Stars: ✭ 32 (-98.87%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
diod
A very opinionated inversion of control (IoC) container and dependency injector for Typescript, Node.js or browser apps.
Stars: ✭ 36 (-98.73%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
Singularity
A extremely fast ioc container for high performance applications
Stars: ✭ 63 (-97.78%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
Ioc
🦄 lightweight (<1kb) inversion of control javascript library for dependency injection written in typescript
Stars: ✭ 171 (-93.96%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
stashbox
A lightweight, fast, and portable dependency injection framework for .NET-based solutions.
Stars: ✭ 120 (-95.76%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
iocgo
A lightweight Inversion of Control (IoC) (Dependency Injection) container for Golang
Stars: ✭ 36 (-98.73%)
Mutual labels:  ioc, dependency-injection, inversion-of-control
Typhoon
Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
Stars: ✭ 2,711 (-4.27%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
nodejs-boilerplate
Clean Architecture for node.js projects (Typescript + Express + TypeORM + Typedi)
Stars: ✭ 199 (-92.97%)
Mutual labels:  dependency-injection, inversion-of-control, typedi
Ditranquillity
Dependency injection for iOS (Swift)
Stars: ✭ 317 (-88.81%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
Go Spring
基于 IoC 的 Go 后端一站式开发框架 🚀
Stars: ✭ 744 (-73.73%)
Mutual labels:  dependency-injection, ioc, inversion-of-control
Python Dependency Injector
Dependency injection framework for Python
Stars: ✭ 1,203 (-57.52%)
Mutual labels:  dependency-injection, ioc
Poodinis
A dependency injection framework for D with support for autowiring.
Stars: ✭ 57 (-97.99%)
Mutual labels:  dependency-injection, ioc

TypeDI

Build Status codecov npm version Dependency Status

TypeDI is a dependency injection tool for TypeScript and JavaScript. With it you can build well-structured and easily testable applications in Node or in the browser.

Main features includes:

  • property based injection
  • constructor based injection
  • singleton and transient services
  • support for multiple DI containers

Installation

Note: This installation guide is for usage with TypeScript, if you wish to use TypeDI without Typescript please read the documentation about how get started.

To start using TypeDI install the required packages via NPM:

npm install typedi reflect-metadata

Import the reflect-metadata package at the first line of your application:

import 'reflect-metadata';

// Your other imports and initialization code
// comes here after you imported the reflect-metadata package!

As a last step, you need to enable emitting decorator metadata in your Typescript config. Add these two lines to your tsconfig.json file under the compilerOptions key:

"emitDecoratorMetadata": true,
"experimentalDecorators": true,

Now you are ready to use TypeDI with Typescript!

Basic Usage

import { Container, Service } from 'typedi';

@Service()
class ExampleInjectedService {
  printMessage() {
    console.log('I am alive!');
  }
}

@Service()
class ExampleService {
  constructor(
    // because we annotated ExampleInjectedService with the @Service()
    // decorator TypeDI will automatically inject an instance of
    // ExampleInjectedService here when the ExampleService class is requested
    // from TypeDI.
    private injectedService: ExampleInjectedService
  ) {}
}

const serviceInstance = Container.get(ExampleService);
// we request an instance of ExampleService from TypeDI

serviceInstance.injectedService.printMessage();
// logs "I am alive!" to the console

Documentation

The detailed usage guide and API documentation for the project can be found:

Contributing

Please read our contributing guidelines to get started.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].