Skip to content

Instantly share code, notes, and snippets.

@stanch
Last active December 30, 2015 03:29
Show Gist options
  • Save stanch/7769231 to your computer and use it in GitHub Desktop.
Save stanch/7769231 to your computer and use it in GitHub Desktop.
Future {
// perform something in background
val url = ...
val data = fetch(url)
process(data)
} mapUi { data ⇒
// this will happen on the UI thread
display(data)
} onFailureUi {
// handle failure on the UI thread
case NonFatal(t) ⇒ t.printStackTrace()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment