Skip to content

Instantly share code, notes, and snippets.

@raulh82vlc
Last active June 8, 2020 21:06
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 raulh82vlc/b59b16062abc0ef07887a5e9100e2070 to your computer and use it in GitHub Desktop.
Save raulh82vlc/b59b16062abc0ef07887a5e9100e2070 to your computer and use it in GitHub Desktop.
TaskThreadingImpl with dispatchers instead of schedulers
class TaskThreadingImpl @Inject constructor() : TaskThreading {
// declaration of dispatchers
private val computationCoroutineDispatcher: CoroutineDispatcher = Default
private val ioCoroutineDispatcher: CoroutineDispatcher = IO
private val mainCoroutineDispatcher: CoroutineDispatcher = Main
// other schedulers here
// dispatchers:
override fun uiDispatcher(): CoroutineDispatcher = mainCoroutineDispatcher
override fun ioDispatcher(): CoroutineDispatcher = ioCoroutineDispatcher
override fun computationDispatcher(): CoroutineDispatcher = computationCoroutineDispatcher
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment