Created
January 19, 2019 13:24
-
-
Save Tgo1014/69f9a2b324dfea3c1c62d92eeae81d21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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