Skip to content

Instantly share code, notes, and snippets.

@myeonginwoo
Created November 4, 2018 17:44
Show Gist options
  • Save myeonginwoo/aa6c8c2f5827f00ee4953c6853cae88e to your computer and use it in GitHub Desktop.
Save myeonginwoo/aa6c8c2f5827f00ee4953c6853cae88e to your computer and use it in GitHub Desktop.
// before
sealed class NetworkState {
class Init : NetworkState()
class Loading : NetworkState()
class Success(val item: Item) : NetworkState()
class Error(val throwable: Throwable?) : NetworkState()
}
// after
sealed class NetworkState<out T> {
class Init : NetworkState<Nothing>()
class Loading : NetworkState<Nothing>()
class Success<out T>(val item: T) : NetworkState<T>()
class Error(val throwable: Throwable?) : NetworkState<Nothing>()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment