Skip to content

Instantly share code, notes, and snippets.

@Tgo1014
Created January 19, 2019 13:24
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 Tgo1014/69f9a2b324dfea3c1c62d92eeae81d21 to your computer and use it in GitHub Desktop.
Save Tgo1014/69f9a2b324dfea3c1c62d92eeae81d21 to your computer and use it in GitHub Desktop.
fun launch(f: () -> Unit) {
GlobalScope.launch {
f.invoke()
}
}
inline fun <reified T> asyncAndWait(crossinline f: () -> T) = runBlocking {
return@runBlocking GlobalScope.async(Dispatchers.IO) {
f.invoke()
}.await()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment