Skip to content

baseclass/inxect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Small library to make dependency injection with elixir easier, see documentation for more infos

Build

Build Status

Documentation

https://hexdocs.pm/inxect

Hex

Hex.pm Hex.pm

Example

defmodule Localizer do
    @callback getHello :: String.t
end

defmodule Greeter do
    use Inxect.DI
    inject :localizer

    @spec sayHello(String.t) :: { :ok, String.t }
    defi sayHello(who, localizer) do
        { :ok, "#{localizer.getHello()} #{who}"}
    end
end

defmodule EnglishLocalizer do
    @behaviour Localizer
    
    @spec getHello :: String.t
    def getHello do
        hello
    end
end

defmodule Registry do
    use Inxect.Registry
    
    register { :localizer, EnglishLocalizer }
end
iex(2)> Greeter.sayHello("Daniel")
{ :ok, "hello Daniel" }

About

dependency injection for elixir

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages