Skip to content

Instantly share code, notes, and snippets.

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 aleksandarzekovic/2c6b6991895e144d07bba3fbd0d9dc16 to your computer and use it in GitHub Desktop.
Save aleksandarzekovic/2c6b6991895e144d07bba3fbd0d9dc16 to your computer and use it in GitHub Desktop.
/**
* param completion is AbstractCoroutine
* return a Continuation
*/
internal fun <R , T> (suspend ( R ) -> T).startCoroutineCancellable(receiver: R, completion: Continuation<T>) =
runSafely(completion) {
createCoroutineUnintercepted(receiver, completion).intercepted().resumeCancellableWith(Result.success(Unit))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment