Skip to content

Instantly share code, notes, and snippets.

@mantisbayne
Last active November 26, 2019 20:10
Show Gist options
  • Save mantisbayne/436f32c3de00826d59e17bfd7a99f420 to your computer and use it in GitHub Desktop.
Save mantisbayne/436f32c3de00826d59e17bfd7a99f420 to your computer and use it in GitHub Desktop.
val myModule = module {
// singleton
single { DataRepository() }
// factory for ExampleUseCase, use get() to resolve the constructor
factory { ExampleUseCase(get()) }
// Define a singleton of type HttpClient ("properties_url" is in Koin properties)
single { HttpClient(getProperty("properties_url")) }
// viewmodel is used for ExampleViewModel
viewModel { ExampleViewModel(get()) }
// Room database instance (we will create this later)
single { Room.databaseBuilder(get(), AppDatabase::class.java, "example_database").build() }
single { get<AppDatabase>().exampleDao() }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment