Skip to content

Instantly share code, notes, and snippets.

@alwarren
Created October 10, 2018 05:45
Show Gist options
  • Save alwarren/4906818a4cf774d8fcad13cf2fe89213 to your computer and use it in GitHub Desktop.
Save alwarren/4906818a4cf774d8fcad13cf2fe89213 to your computer and use it in GitHub Desktop.
From RxJava async to Coroutines in two lines of code.
val job = GlobalScope.async(Dispatchers.Default, CoroutineStart.DEFAULT, { MyApi.execute() })
GlobalScope.launch(Dispatchers.Main, CoroutineStart.DEFAULT, { updateUi(job.await()) })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment