Skip to content
This repository was archived by the owner on Dec 29, 2024. It is now read-only.

darky/glency

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

glency

Deprecated in favor klubok-gleam

Package Version Hex Docs Erlang-compatible JavaScript-compatible

Tiny Gleam dependency injection. Make IO functions unit tests friendly.

gleam add glency
import glency

type Cat {
  Cat(name: String, age: Int)
}

pub fn main() {
  glency.init_di() // Firstly init DI container on application startup

  {
    // Mock implementation of `fetch_cat`
    use <- glency.with_di(fetch_cat, fn(_cat_id) { Cat("Barsik", 7) })
    fetch_cat(1) // will avoid IO, returns Barsik cat
  }
}

pub fn fetch_cat(cat_id: Int) {
  use <- glency.di(fetch_cat, #(cat_id)) // Make IO function DI friendly
  // Here production IO implementation of function
}

Further documentation can be found at https://hexdocs.pm/glency.

Development

gleam run   # Run the project
gleam test  # Run the tests
gleam shell # Run an Erlang shell

About

Tiny Gleam dependency injection. Make IO functions unit tests friendly.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors