: FavoriteListState() data class Data(val data: List<Favorite>) : FavoriteListState() data class Error(@StringRes val message: Int) : FavoriteListState() } View State
render(state: FavoriteListState) { when (state) { FavoriteListState.Loading -> showLoading() FavoriteListState.Empty -> showEmpty() is FavoriteListState.Data -> showContent(state.data) is FavoriteListState.Error -> showError(state.message) } } } One responsibility – to render the given state
HomeStateReducer = { when (favorites) { is Result.Data -> FavoriteListState.Data(favorites.data) is Result.Error -> FavoriteListState.Error() is Result.Loading -> FavoriteListState.Loading is Result.Nothing -> FavoriteListState.Empty } }