Last active
November 29, 2016 02:35
-
-
Save LewisRhine/e2802ef8c68187701d8600dbc0257756 to your computer and use it in GitHub Desktop.
Running when over restaurantNearby state tree
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
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