Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vantoozz/dikt
Dependency Injection library for Kotlin
https://github.com/vantoozz/dikt
dependency-injection kotlin
Last synced: about 1 month ago
JSON representation
Dependency Injection library for Kotlin
- Host: GitHub
- URL: https://github.com/vantoozz/dikt
- Owner: vantoozz
- License: mit
- Created: 2022-02-14T22:15:32.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-09-08T20:31:05.000Z (4 months ago)
- Last Synced: 2024-09-08T21:42:31.312Z (4 months ago)
- Topics: dependency-injection, kotlin
- Language: Kotlin
- Homepage:
- Size: 368 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Dikt
Dependency Injection library for Kotlin
[![Maven Central](https://img.shields.io/maven-central/v/io.github.vantoozz/dikt)](https://mvnrepository.com/artifact/io.github.vantoozz/dikt/latest)
[![build](https://github.com/vantoozz/dikt/actions/workflows/build.yml/badge.svg)](https://github.com/vantoozz/dikt/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/vantoozz/dikt/branch/master/graph/badge.svg?token=J6SYG3WAP0)](https://codecov.io/gh/vantoozz/dikt)```kotlin
import io.github.vantoozz.dikt.dikt
import io.github.vantoozz.dikt.putdata class DBConnection( // Some fake service
val url: String,
)class MyService( // Another service
private val db: DBConnection, // depending on the fake one
) {
fun run() =
println("Connecting to ${db.url}")
}fun main() {
val container = dikt { // We're creating a container object
put { // and putting a definition
DBConnection("some_url") // of the fake service
} // into it
}val myService = container[MyService::class] // And then the container
// creates an object for usmyService?.run() // Prints "Connecting to some_url"
}
```