All Projects → dimes → Dihedral

dimes / Dihedral

Licence: mit
Compile-time dependency injection for Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Dihedral

Complex Redux Project Architecture
Redux architecture extended with a layer of services.
Stars: ✭ 53 (-30.26%)
Mutual labels:  dependency-injection
Singularity
A extremely fast ioc container for high performance applications
Stars: ✭ 63 (-17.11%)
Mutual labels:  dependency-injection
Android App Architecture Mvvm Databinding
A simple but complete project (in both Java & Kotlin) to demonstrate the Android application architecture with MVVM pattern, a client app for The Movie DB Web API. Dagger2 is used for dependency injection and RxJava is used for RFP (Reactive Functional Programming).
Stars: ✭ 69 (-9.21%)
Mutual labels:  dependency-injection
Macwire
Lightweight and Nonintrusive Scala Dependency Injection Library
Stars: ✭ 1,095 (+1340.79%)
Mutual labels:  dependency-injection
Rea Di
Dependency injection for React done right. Hierarchical injection on both component and service layer powered by injection-js (Angular DI framework) 🖖
Stars: ✭ 62 (-18.42%)
Mutual labels:  dependency-injection
Daggraph
Dagger dependency graph generator for Android Developers
Stars: ✭ 1,140 (+1400%)
Mutual labels:  dependency-injection
Aiodine
🧪 Async-first Python dependency injection library
Stars: ✭ 51 (-32.89%)
Mutual labels:  dependency-injection
Vuec
A simple IoC container for VueJS 2
Stars: ✭ 72 (-5.26%)
Mutual labels:  dependency-injection
Lagom
📦 Autowiring dependency injection container for python 3
Stars: ✭ 61 (-19.74%)
Mutual labels:  dependency-injection
Di
psr/container implementation for humans
Stars: ✭ 69 (-9.21%)
Mutual labels:  dependency-injection
Danf
Danf is a Node.js full-stack isomorphic OOP framework allowing to code the same way on both client and server sides. It helps you to make deep architectures and handle asynchronous flows in order to help in producing scalable, maintainable, testable and performant applications.
Stars: ✭ 58 (-23.68%)
Mutual labels:  dependency-injection
Fx Guice
Google Guice integration for FXML-based JavaFX applications
Stars: ✭ 61 (-19.74%)
Mutual labels:  dependency-injection
App
Reusable framework for micro services & command line tools
Stars: ✭ 66 (-13.16%)
Mutual labels:  dependency-injection
Poodinis
A dependency injection framework for D with support for autowiring.
Stars: ✭ 57 (-25%)
Mutual labels:  dependency-injection
Bottlejs
A powerful dependency injection micro container for JavaScript applications
Stars: ✭ 1,171 (+1440.79%)
Mutual labels:  dependency-injection
Simplify
Simplify is a set of .NET libraries that provide infrastructure for your applications. DI and mocking friendly.
Stars: ✭ 52 (-31.58%)
Mutual labels:  dependency-injection
Typesafeconfig Guice
Allows Guice Injection of configuration values from Typesafe Config
Stars: ✭ 64 (-15.79%)
Mutual labels:  dependency-injection
Flutter Boilerplate Project
A boilerplate project created in flutter using MobX and Provider.
Stars: ✭ 1,194 (+1471.05%)
Mutual labels:  dependency-injection
Foal
Elegant and all-inclusive Node.Js web framework based on TypeScript. 🚀.
Stars: ✭ 1,176 (+1447.37%)
Mutual labels:  dependency-injection
Pure Swift Dependency Injection
Dependency Injection in Pure Swift
Stars: ✭ 67 (-11.84%)
Mutual labels:  dependency-injection

Dihedral

Build Status

Dihedral is a compile-time injection framework for Go.

Getting started

> go get -u github.com/dimes/dihedral

Create a type you want injected:

type ServiceEndpoint string  // Name this string "ServiceEndpoint"
type Service struct {
    inject  embeds.Inject    // Auto-inject this struct 
    Endpoint ServiceEndpoint // Inject a string with name "ServiceEndpoint"
}

Create a module to provide non-injected dependencies:

// Each public method on this struct provides a type
type ServiceModule struct {}
func (s *ServiceModule) ProvidesServiceEndpoint() ServiceEndpoint {
    return ServiceEndpoint("http://hello.world")
}

Create a component as the root of the dependency injection:

type ServiceComponent interface {
    InjectService() *Service
}

Create a definition with the target component and the module configuration:

type ServiceDefinition interface {
    Modules() (*ServiceModule, dbstore.DBBindingModule)
    Target() ServiceComponent
}

Generate the bindings

> dihedral -definition ServiceDefinition

Use the bindings

func main() {
    // dihedral generates the digen package
    component := digen.NewDihedralServiceComponent()
    service := component.InjectService()
    fmt.Println(string(injected.Endpoint)) # Prints "http://hello.world"
}

Further Reading

Differences from Wire

Wire, Google's injection framework, is another compile time framework for Go. Both frameworks are inspired by Dagger. Dihedral differs from Wire in that Dihedral focuses on auto-injected components and self-contained modules, whereas Wire focuses more on type registration via provider functions. Dihedral also leverages struct receivers for better organization of runtime provided types. These features make Dihedral nicer to work with.

Dihedral's component structure also enables one to have multiple injected components that share modules. The type annotation system allows for auto-injected components, provided modules, and, in the future, sub-components that have a different scope than the parent component.

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].