Skip to content

Instantly share code, notes, and snippets.

@ThomasGorisse
Created October 19, 2021 20:23
Show Gist options
  • Save ThomasGorisse/2353eba7ff3940378341731defbc4349 to your computer and use it in GitHub Desktop.
Save ThomasGorisse/2353eba7ff3940378341731defbc4349 to your computer and use it in GitHub Desktop.
textView.lifecycleScope.launchWhenCreated {
while (isActive) {
view.text = "${System.currentTimeMillis()}" // Dispatchers.Main
withContext(Dispatchers.IO) { // Dispatchers.IO for waiting in background
delay(1000) // Wait 1 second
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment