Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Created June 4, 2021 13:10
Show Gist options
  • Save manuelvicnt/c07227a08a89ac95f71f0b3ac82bbd34 to your computer and use it in GitHub Desktop.
Save manuelvicnt/c07227a08a89ac95f71f0b3ac82bbd34 to your computer and use it in GitHub Desktop.
@InstallIn(SingletonComponent::class)
@Module
object CoroutinesDispatchersModule {
@DefaultDispatcher
@Provides
fun providesDefaultDispatcher(): CoroutineDispatcher = Dispatchers.Default
@IoDispatcher
@Provides
fun providesIoDispatcher(): CoroutineDispatcher = Dispatchers.IO
@MainDispatcher
@Provides
fun providesMainDispatcher(): CoroutineDispatcher = Dispatchers.Main
@MainImmediateDispatcher
@Provides
fun providesMainImmediateDispatcher(): CoroutineDispatcher = Dispatchers.Main.immediate
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment