https://github.com/darky/glency
Tiny Gleam dependency injection. Make IO functions unit tests friendly.
https://github.com/darky/glency
dependency gleam injection
Last synced: about 1 year ago
JSON representation
Tiny Gleam dependency injection. Make IO functions unit tests friendly.
- Host: GitHub
- URL: https://github.com/darky/glency
- Owner: darky
- Archived: true
- Created: 2024-07-07T17:03:25.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-29T19:18:42.000Z (over 1 year ago)
- Last Synced: 2025-04-25T21:52:19.070Z (about 1 year ago)
- Topics: dependency, gleam, injection
- Language: Gleam
- Homepage:
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# glency
## Deprecated in favor [klubok-gleam](https://github.com/darky/klubok-gleam)
[](https://hex.pm/packages/glency)
[](https://hexdocs.pm/glency/)


Tiny Gleam dependency injection. Make IO functions unit tests friendly.
```sh
gleam add glency
```
```gleam
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 .
## Development
```sh
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell
```