1. Declare your modules by extending ShankModule
, where you specify how the object should be created
object MyModule: ShankModule() {
val alwaysNew = new { -> Random() }
val myClassDependency = singleton { -> MyClass() }
val dependencyWithParam = singleton { p: String -> OtherClass(p) }
}
registerModules(MyModule, SomeOtherModule, ...)
fun myCode() {
...
blah.foo()
...
myClassDependency().callSomeMethodOfMyClass()
dependencyWithParam("foooo").callSomeMethodOfOtherClass()
alwaysNew().nextInt()
...
blah.blah()
...
}
That's the end of the tutorial, you know how this library works. Now you can go have some actual coffee.