Skip to content

Instantly share code, notes, and snippets.

@LewisRhine
Last active November 29, 2016 02:35
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 LewisRhine/e2802ef8c68187701d8600dbc0257756 to your computer and use it in GitHub Desktop.
Save LewisRhine/e2802ef8c68187701d8600dbc0257756 to your computer and use it in GitHub Desktop.
Running when over restaurantNearby state tree
when (restaurantNearby) {
is RestaurantNearby.Loading -> // Tell user the data is loading
is RestaurantNearby.Loading.Done -> {
restaurantNearby.reloadData() // Attach this function to some user feedback.
when (restaurantNearby) {
is RestaurantNearby.Loading.Done.Ready -> restaurantNearby.restaurants // Do something with this list.
is RestaurantNearby.Loading.Done.Empty -> // Tell the user there was no data found.
is RestaurantNearby.Loading.Done.Error -> {
restaurantNearby.message // Show this message to the user.
restaurantNearby.throwable // Catch this and act on it as needed.
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment