All Projects → wookieb → alpha-dic

wookieb / alpha-dic

Licence: MIT License
Powerful dependency injection container for node.js

Programming Languages

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

Projects that are alternatives of or similar to alpha-dic

Disco
PSR-11 compatible Dependency Injection Container for PHP.
Stars: ✭ 135 (+400%)
Mutual labels:  ioc, dependency-injection, ioc-container
DependencyInjector
Lightweight dependency injector
Stars: ✭ 30 (+11.11%)
Mutual labels:  ioc, dependency-injection, ioc-container
Node Dependency Injection
The NodeDependencyInjection component allows you to standarize and centralize the way objects are constructed in your application.
Stars: ✭ 140 (+418.52%)
Mutual labels:  ioc, dependency-injection, ioc-container
Reflex
Minimal dependency injection framework for Unity
Stars: ✭ 263 (+874.07%)
Mutual labels:  ioc, dependency-injection, ioc-container
ashley
Ashley is a dependency injection container for JavaScript.
Stars: ✭ 23 (-14.81%)
Mutual labels:  ioc, dependency-injection, ioc-container
React Ioc
Hierarchical Dependency Injection with new React 16 Context API
Stars: ✭ 133 (+392.59%)
Mutual labels:  ioc, dependency-injection, ioc-container
inject
[Archived] See https://github.com/goava/di.
Stars: ✭ 49 (+81.48%)
Mutual labels:  ioc, dependency-injection, ioc-container
Poodinis
A dependency injection framework for D with support for autowiring.
Stars: ✭ 57 (+111.11%)
Mutual labels:  ioc, dependency-injection, ioc-container
stashbox
A lightweight, fast, and portable dependency injection framework for .NET-based solutions.
Stars: ✭ 120 (+344.44%)
Mutual labels:  ioc, dependency-injection, dependency-injection-container
Typhoon
Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
Stars: ✭ 2,711 (+9940.74%)
Mutual labels:  ioc, dependency-injection, ioc-container
SwiftInjection
Dependency Injection framework for Swift
Stars: ✭ 21 (-22.22%)
Mutual labels:  ioc, dependency-injection, ioc-container
vesselize
⛵ A JavaScript IoC container that works seamlessly with Vue.js and React.
Stars: ✭ 22 (-18.52%)
Mutual labels:  ioc, dependency-injection, ioc-container
Python Dependency Injector
Dependency injection framework for Python
Stars: ✭ 1,203 (+4355.56%)
Mutual labels:  ioc, dependency-injection, ioc-container
di
🛠 A full-featured dependency injection container for go programming language.
Stars: ✭ 156 (+477.78%)
Mutual labels:  ioc, dependency-injection, ioc-container
Singularity
A extremely fast ioc container for high performance applications
Stars: ✭ 63 (+133.33%)
Mutual labels:  ioc, dependency-injection, ioc-container
Container
A lightweight yet powerful IoC container for Go projects
Stars: ✭ 160 (+492.59%)
Mutual labels:  ioc, dependency-injection, ioc-container
Typescript Ioc
A Lightweight annotation-based dependency injection container for typescript.
Stars: ✭ 427 (+1481.48%)
Mutual labels:  ioc, dependency-injection, ioc-container
Di
Dependency Injection and IoC framework for PHP
Stars: ✭ 5 (-81.48%)
Mutual labels:  ioc, dependency-injection, ioc-container
Ioc
🦄 lightweight (<1kb) inversion of control javascript library for dependency injection written in typescript
Stars: ✭ 171 (+533.33%)
Mutual labels:  ioc, dependency-injection, ioc-container
iocgo
A lightweight Inversion of Control (IoC) (Dependency Injection) container for Golang
Stars: ✭ 36 (+33.33%)
Mutual labels:  ioc, dependency-injection, ioc-container

Alpha DIC

CircleCI Coverage Status

Flexible Dependency Injection Container with support for asynchronous service creation, annotations and middlewares.

Features:

  • Autowiring
  • Supports middlewares
  • Allows to define service as constructor, (async) factory or a value
  • Detects cycle dependencies
  • Prevents race condition for concurrent service requests
  • Supports annotations (and ability to search services by annotations)
  • Simple service definition via container methods or decorators

Installation

npm install alpha-dic

Example

import {createStandard} from 'alpha-dic';

const container = createStandard();
// if you're defining services via decorators
// preloadServiceModules(container, './path/to/service/modules/*')

container.definitionWithFactory('my-service', async () => {
        const connection = new DatabaseConnection();
        await connection.connect();
        return connection;
    });

container.get('my-service').then((connection) => {
    // connection has been established in factory
});

Example with dependencies and decorators

import {createStandard, reference, AutowiredService, Service, OnActivation} from 'alpha-dic';
import * as assert from 'assert';

const container = createStandard();

@AutowiredService('NotificationCenter')
class NotificationCenter {
    constructor(renderer: EmailRenderer, sender: EmailSender) {
        assert.ok(renderer instanceof EmailRenderer);
        // connection to SMTP was established in factory
        assert.ok(sender instanceof EmailSender);
    }
    async sendEmail(to, type, vars) {
        // render email
        // send it via sender
    }
}

@Service()
class EmailRenderer {
    
}

@Service()
@OnActivation(async (mailer) => {
    await mailer.connectToSMTP();
    return mailer;
})
class EmailSender {
    
}

container.get('NotificationCenter')
    .then((centre) => {
        return centre.sendEmail('[email protected]', 'limits-exceeded', {})
    })
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].