Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Flipping the Koin

Flipping the Koin

Slides of the talk I gave at Kotlin/Everywhere in Stockholm, St. Petersburg and Milan

Roberto Orgiu

November 27, 2019
Tweet

More Decks by Roberto Orgiu

Other Decks in Programming

Transcript

  1. R O B E R T O O R G

    I U - @ _ t i w i z Flippin’ the Koin
  2. modules declaration val myModule = module { single<Target> { TargetImpl()

    } factory { (view: View) -> Presenter(view, get() } viewModel { MyViewModel(get()) } }
  3. Injection class MyWorker : KoinComponent { override suspend fun doWork():

    Result { val target: Target by inject() ... } }
  4. startKoin class MyTest : KoinTest { @Before fun setup() {

    startKoin { androidContext(context) modules(fetchModules()) } } }
  5. startKoin class MyTest : KoinTest { @Before fun setup() {

    startKoin { androidContext(context) modules(fetchModules()) } } }
  6. class MyTest : KoinTest { @Before fun setup() { startKoin

    {...} } @Test fun my_test() { } } private val target: Target by inject() declareMock<Target>() given(target).will { throw Exception() }