singleton single { Repository() } // new instance each time factory { Factory() } // instance depends on scope scope { Scoped() } } // constructor injection val sampleModule = { single { Repository(get(), get()) } } // parameter injection val repository: Repository by inject()
match type Service only single<Service> { ServiceImpl() } // match type Service only single { ServiceImpl() as Service } // match types ServiceImpl & Service single { ServiceImpl() } bind Service::class • koinはKlassをkeyにして instanceをmapで管理 している • mapに複数のkeyに対し て設定できる Type Binding