Skip to content

Instantly share code, notes, and snippets.

@TorkelV
Last active October 20, 2020 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TorkelV/ea127b5e14596545de0556010f50f583 to your computer and use it in GitHub Desktop.
Save TorkelV/ea127b5e14596545de0556010f50f583 to your computer and use it in GitHub Desktop.
val phraseModule = module {
viewModel { PhraseViewModel(get()) }
single<PhraseDatabase> {
Room.databaseBuilder(
get(),
PhraseDatabase::class.java, "database-name"
).build()
}
single { PreferenceService(get()) }
fun provideDao(db: PhraseDatabase): PhraseDao = db.phraseDao()
single<PhraseDao> { provideDao(get()) }
}
class App : Application() {
override fun onCreate() {
super.onCreate()
startKoin {
androidContext(this@App)
modules(listOf(phraseModule))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment