Created
April 24, 2021 20:42
-
-
Save ferazog/83ae70bb44c5ba48465de1b53e2937b5 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 ejecutarCoroutine() { | |
GlobalScope.launch() { | |
val user = obtenerUsuarioDesdeRed() | |
} | |
Thread.sleep(1_000) | |
} | |
// Retorna un Usuario modelado es este ejemplo por un String | |
suspend fun obtenerUsuarioDesdeRed(): String { // Usa la palabra clave suspend para soportar funciones suspendidas | |
delay(500) // La función delay es soportada, en caso contrario se mostraría un error en tiempo de codificación | |
return "Felipe" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment