kotlin-inject v0.4.1 Release Notes

Release Date: 2022-01-01 // over 2 years ago
  • ๐Ÿ”„ Changed

    • ๐Ÿ‘Œ Improved generated code formatting.
    • โœ‚ Removed explicit retention annotation to get rid of kotlin js warnings.

    ๐Ÿ›  Fixed

    • ๐Ÿ›  Fixes conflicting declarations when scoped @Provides functions returned the same type with different generic args.
    • ๐Ÿ›  Fixes default parameter handling with lambda or lazy values.
    • ๐Ÿ›  Fixes to kotlin native implementation that should make it more usable across threads. Note: the new memory model limitation is still present, but you can use https://github.com/touchlab/Stately to wrap the access when using the legacy memory model.

Previous changes from v0.4.0

  • ๐Ÿ”„ Changed

    • โšก๏ธ Updated kotlin to 1.5.31
    • โšก๏ธ Updated ksp to 1.5.31-1.0.1
    • Several improvements to code generation which often means less code is generated.

    โž• Added

    • ๐Ÿ‘ Multiple rounds handling: This includes support for using types generated by other ksp processors. As a side effect there is better error reporting for unresolved types.
    • ๐Ÿ‘Œ Support for multiplatform/native. Check out the sample project.

    Note: components are thread-safe, however you will run into issues actually using them from other threads unless you enable the new memory model.

    • โž• Added support for default args when injecting. If the type is present in the graph, it'll be injected, otherwise the default will be used.
      @Inject class MyClass(val dep: Dep = Dep("default"))
    
      @Component abstract ComponentWithDep {
          abstract val myClass: MyClass
          @Provides fun dep(): Dep = Dep("injected")
      }
      @Component abstract ComponentWithoutDep {
          abstract val myClass: MyClass
      }
    
      ComponentWithDep::class.create().myClass.dep // Dep("injected")
      ComponentWithoutDep::class.create().myClass.dep // Dep("default")