All Versions
61
Latest Version
Avg Release Cycle
18 days
Latest Release
1826 days ago

Changelog History
Page 7

  • v0.2.x Changes

    ๐Ÿ”€ Koin & Koin-Android project has meen merged

    DSL

    • Module/AndroidModule class must now give a context() function implementation, to return a Context object. The declareContext function unlock the Koin DSL to describe dependencies and injection:
    class MykModule : Module() {
        override fun context() = declareContext { ... }
    }
    
    • You can now bind additional types for provided definitions Kotlin class MykModule : Module() { override fun context() = declareContext { provide { Processor() } bind { ProcessorInterface::class} } }

    Scope

    • ๐Ÿ‘€ You can declare/reuse paths in your modules, with modulePath {} operator. See paths section
    • ๐Ÿš€ Release modulePath instances with release() on a KoinContext
    class MainActivityModule : Module() {
        override fun context() =
                declareContext {
                    // Scope MainActivity
                    modulePath { MainActivity::class }
                    // provided WeatherService
                    provide { WeatherService(get()) }
                }
    }
    

    Android

    • ๐Ÿšš KoinAwareContext interface used to setup Android application (KoinApplication & KoinMultidexApplication are removed)
    class MainApplication : Application(), KoinContextAware {
    
         /**
         * Koin context
         */
        lateinit var context: KoinContext
    
        /**
         * KoinContextAware - Retrieve Koin Context
         */
        override fun getKoin(): KoinContext = context
    
        override fun onCreate() {
            super.onCreate()
            // insert Koin !
            context = Koin().init(this).build(MyModule()) 
            // ...
        }
    }
    
    • by inject<>() function operator to inject any dependency in any Activity or Fragment
    class MainActivity : AppCompatActivity() {
    
        // inject my WeatherService 
        val weatherService by inject<WeatherService>()
    }
    

    Koin

    • ๐Ÿ— Koin builder takes module instances (instead of module classes):
    // fill applicationContext for Koin context
    val ctx = Koin().init(applicationContext).build(Module1(),Module2()...)
    

    Internal rework for simpler use with Scopes:

    • ๐Ÿ— Koin().build() return KoinContext
    • ๐Ÿšš factory, stack operators have been removed, for the modulePath fatures
    • โœ‚ delete/remove replaced with release() Scope operation
    • import is replaced with module instances load
    • ๐Ÿšš All reflection & kotlin-reflect code have been removed