DI
KOtlin DEpendency INjection.
To construct a DI instance, simply use it's block constructor and define your bindings in it :
val di = DI {
bind<Dice>() with factory { sides: Int -> RandomDice(sides) }
bind<DataSource>() with singleton { SqliteDS.open("path/to/file") }
bind<Random>() with provider { SecureRandom() }
constant("answer") with "forty-two"
}Content copied to clipboard
Types
Bind Builder
Link copied to clipboard
Base builder DSL interface that allows to define scoped and context bindings.
Builder
Link copied to clipboard
Allows for the DSL inside the block argument of the constructor of DI and DI.Module.
Dependency Loop Exception
Link copied to clipboard
Exception thrown when there is a dependency loop.
Key
Link copied to clipboard
Main Builder
Link copied to clipboard
Builder to create a DI object.
No Result Exception
Link copied to clipboard
class NoResultException(search: SearchSpecs, message: String) : RuntimeException
Content copied to clipboard
Exception thrown when searching for bindings and none could be found.
Not Found Exception
Link copied to clipboard
class NotFoundException(key: DI.Key<*, *, *>, message: String) : RuntimeException
Content copied to clipboard
Exception thrown when asked for a dependency that cannot be found.
Overriding Exception
Link copied to clipboard
Exception thrown when there is an overriding error.