Skip to content

IoC implementation for Kotlin/Multiplatform using DSL for configuration, supports multithreading.

License

Notifications You must be signed in to change notification settings

angelos-project/angelos-project-ioc

Repository files navigation

Inversion of Control for Kotlin with DSL

IoC implementation for Kotlin/Multiplatform with multithreading.

CircleCI Codacy Badge

import org.angelos.ioc.Config
import org.angelos.ioc.Container
import org.angelos.ioc.Module

// Implementing a custom module type for the container, 
// which represents an item.
open class ExampleModule : Module

// Creating modules that can be dispatched as services.
class Module1 : ExampleModule()

class Module2 : ExampleModule()

class Module3(val one: Module1, val two: Module2) : ExampleModule()


// The IoC implementation.
class ExampleContainer : Container<String, ExampleModule>() {
    operator fun invoke(block: ExampleContainer.() -> Config<String, ExampleModule>) = config { block() }
}


fun main() {
    val ioc = ExampleContainer()
    ioc {
        mapOf(
            "one" to { Module1() },
            "two" to { Module2() },
            "three" to { Module3(get("one"), get("two")) }
        )
    }

    val three: Module3 = ioc["three"]
}

About

IoC implementation for Kotlin/Multiplatform using DSL for configuration, supports multithreading.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages