Romman Sabbir
Romman's Blog

Romman's Blog

Kotlin's Coroutine Extension Functions

Kotlin's Coroutine Extension Functions

Kotlin's Coroutine extension functions to switch from one context to another one. Supports [Dispatchers.IO], [Dispatchers.Main], [Dispatchers.Default

Romman Sabbir's photo
Romman Sabbir
·Feb 17, 2022·

1 min read

Usages:

scope.toMain{ /*this: CoroutineScope */
// Write your code here
}

scope.toIO{ /*this: CoroutineScope */
// Write your code here
}

scope.toDefault{ /*this: CoroutineScope */
// Write your code here
}

scope.toUnconfined{ /*this: CoroutineScope */
// Write your code here
}

Follow Me on LinkedIn

 
Share this