Skip to content

Wrapped-Owls/goremy-di

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Remy

A package that helps the creation of golang dependency injections.

About

The main job of a dependency-injection package is to help providing objects, instances, closures to a caller, by avoiding a depth graph in parameter pass. Knowing this, and using culinary as inspiration, we thought that a DI (dependency injection) package is like a Sous chef in a cuisine, so we take decided to reference the best Sous chef we know: " Remy"!

Inspiration

This package is heavily inspired by the flutter module Modular Dependency Injection

Instance registration

The strategy for building an instance with its dependencies comprise on registering all objects in a module and instantiate them on demand or in single-instance form(singleton). This 'registration' is called Bind.

There are a few ways to build a Bind to register object instances:

  • Bind.singleton: Build an instance only once at the bind registration.
  • Bind.lazySingleton: Build an instance only once when element is retrieved at first time.
  • Bind.factory: Build an instance on demand.
  • Bind.instance: Adds an existing instance as it is.

Other information about binds, functions and injectors can be found easily at spec