Kodein v3.0.0-beta1 Release Notes
Release Date: 2016-06-29 // almost 8 years ago-
BREAKING CHANGES
JKodein
is replaced byTKodein
which is meant to use by both Kotlin & Java.TKodein
allows you to access a type consistent API withoutinline
methods. Each method can be used withType
,TypeToken
, orClass
. To access aTKodein
, simply usekodein.typed
.- The
typeToken
function now returns aTypeToken
interface. This allows to keep type consistency & checking whileType
objects. If you were usingval t = typeToken<T>()
in Kodein 2, the replacement is simplyval t = typeToken<T>().type
. kodein.bindingsDescription
becomeskodein.container.bindings.description
.kodein.registeredBindings
becomeskodein.container.bindings
.- All
inline
functions that usereified
to get the type are now extension functions, which means that they need to be imported! Your code will be all red until you resolve those import. Don't panic! The API itself has not changed, just its imports.
FEATURES
- Introducing
kodein.container
which enables you to query the Kodein container directly withKodein.Key
orKodein.Bind
objects. kodein.container.bindings
now gives aMap<Kodein.Key, Factory<*, *>>
. Which means that you can do all sorts of introspection and debug (like know which types are bounds to which factories, etc.). To help you with those tasks, several extension functions are proposed to thisMap
(in the filebindings.kt
).- Better bindings description: now displays the bound type and the created (real) type.
- Introducing the
KodeinAware
andKodeinInjected
interfaces. If a class implements one of those interfaces, the injection feels "native":instance()
instead ofkodein.instance()
. - Introducing
instanceForClass()
andproviderForClass()
: those methods can be passed aKodein
orKodeinInjector
object to inject an instance by using a factory that takes aKClass<*>
as parameter. Those functions can be used without parameter on aKodeinAware
orKodeinInjected
class (which is where they reach their full potential!). - Introducing
Kodein.global
which is a global Kodein instance for all. It is on its module and is not proposed by default. To use it, you must declare the dependencyorg.kodein:kodein-global:3.0.+
. You can add modules to it withKodein.global.addImport(module)
. After that, you can useKodein.global
as a regular Kodein object. Be aware that once you have injected / retrieved the first value withKodein.global
, then adding modules to it will throw an exception. - When using
Kodein.global
, you can use theKodeinGlobalAware
interface, which enables you all the goodness ofKodeinAware
, but usingKodein.global
, and without any config. - Kotlin
1.0.2-1
- Introducing
INTERNAL
- All providers & factories are represented by their classes.
Kodein
,TKodein
andKodeinContainer
are now very simple interfaces, which enables easy wrapping.