Skip to content

Instantly share code, notes, and snippets.

@myeonginwoo
Created November 4, 2018 17:44
Show Gist options
  • Select an option

  • Save myeonginwoo/aa6c8c2f5827f00ee4953c6853cae88e to your computer and use it in GitHub Desktop.

Select an option

Save myeonginwoo/aa6c8c2f5827f00ee4953c6853cae88e to your computer and use it in GitHub Desktop.

Revisions

  1. myeonginwoo created this gist Nov 4, 2018.
    15 changes: 15 additions & 0 deletions dk_mvvm_9.kt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    // 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>()
    }