$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Flipping the Koin @ GDG Dev Party
Search
Roberto Orgiu
May 02, 2020
Programming
1
65
Flipping the Koin @ GDG Dev Party
Slides of my talk at GDG Dev Party Italy 2020
Roberto Orgiu
May 02, 2020
Tweet
Share
More Decks by Roberto Orgiu
See All by Roberto Orgiu
Wellness & Droid
tiwiz
0
110
Behind the curtains
tiwiz
0
58
The Importance of Being Tested
tiwiz
0
410
An Android Dev start to Kotlin MPP
tiwiz
0
170
Fantastic API and where to find them
tiwiz
0
69
Flipping the Koin
tiwiz
2
150
Trip into the async world @ NYC Kotlin Meetup
tiwiz
0
110
Trip into the async world
tiwiz
1
130
GraphQL IRL (Android Makers)
tiwiz
0
150
Other Decks in Programming
See All in Programming
TypeScript 5.9 で使えるようになった import defer でパフォーマンス最適化を実現する
bicstone
1
1k
AI時代もSEOを頑張っている話
shirahama_x
0
230
【CA.ai #3】Google ADKを活用したAI Agent開発と運用知見
harappa80
0
260
エディターってAIで操作できるんだぜ
kis9a
0
650
俺流レスポンシブコーディング 2025
tak_dcxi
13
7.8k
MAP, Jigsaw, Code Golf 振り返り会 by 関東Kaggler会|Jigsaw 15th Solution
hasibirok0
0
210
「文字列→日付」の落とし穴 〜Ruby Date.parseの意外な挙動〜
sg4k0
0
360
バックエンドエンジニアによる Amebaブログ K8s 基盤への CronJobの導入・運用経験
sunabig
0
140
堅牢なフロントエンドテスト基盤を構築するために行った取り組み
shogo4131
6
2k
目的で駆動する、AI時代のアーキテクチャ設計 / purpose-driven-architecture
minodriven
11
3.9k
宅宅自以為的浪漫:跟 AI 一起為自己辦的研討會寫一個售票系統
eddie
0
470
[SF Ruby Conf 2025] Rails X
palkan
0
440
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Producing Creativity
orderedlist
PRO
348
40k
Leading Effective Engineering Teams in the AI Era
addyosmani
8
1.2k
Code Reviewing Like a Champion
maltzj
527
40k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
Designing for Performance
lara
610
69k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Making Projects Easy
brettharned
120
6.5k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Done Done
chrislema
186
16k
Transcript
R O B E R T O O R G
I U - @ _ t i w i z Flippin’ the Koin
Is there a difference? IMPLEMENTATION DI vs SL
DI Container Should only call itself Never called by others
Constructs objects
Service Locator Container Dependency
I’m not really answering this question WHAT IS DAGGER?
@Inject lateinit var myTarget: Target myComponent.inject(this) val myTarget = myComponent.getTarget()
insert-koin.io
Why I like it Kotlin DSL Quick setup Easy to
follow
I’m not really answering this question either WHAT IS KOIN?
private val target: Target by inject() inline fun <reified T
: Any> ComponentCallbacks.inject()
modules declaration val myModule = module { single<Target> { TargetImpl()
} factory { (view: View) -> Presenter(view, get() } viewModel { MyViewModel(get()) } }
Injection private val target: Target by inject { parametersOf(this) }
Injection private val target: Target by inject { parametersOf(this) }
Injection private val target: Target by inject { parametersOf(this) }
Injection val viewModel: MyViewModel by viewModel()
Injection class MyWorker : KoinComponent { override suspend fun doWork():
Result { val target: Target by inject() ... } }
Application startKoin { androidContext(context) androidLogger() modules( listOf(module1,..., moduleN) ) }
Let’s talk about testing “
JUnit + KoinTest
Dependencies koinApplication { androidContext(context) modules(fetchModules()) }.checkModules()
Dependencies koinApplication { androidContext(context) modules(fetchModules()) }.checkModules { create<MyClass> { parametersOf(mock1,...,paramN)
} }
Building a test
startKoin class MyTest : KoinTest { @Before fun setup() {
startKoin { androidContext(context) modules(fetchModules()) } } }
startKoin class MyTest : KoinTest { @Before fun setup() {
startKoin { androidContext(context) modules(fetchModules()) } } }
startKoin stopKoin class MyTest : KoinTest { @After fun tearDown()
{ stopKoin() } }
startKoin stopKoin class MyTest : KoinTest { @After fun tearDown()
{ stopKoin() } }
startKoin stopKoin Test
class MyTest : KoinTest { @Before fun setup() { startKoin
{...} } @Test fun my_test() { } }
class MyTest : KoinTest { @Before fun setup() { startKoin
{...} } @Test fun my_test() { } } private val target: Target by inject() declareMock<Target>() given(target).will { throw Exception() }
Dagger VS Koin
WARNING: Opinionated Ideas ahead
We should use Dagger
Quick setup
Compile time safety Because we all love it.
Scalability
Maintainability
androiddevs.it
Use the tools You Like the most
Thanks!