Skip to content

Instantly share code, notes, and snippets.

@booknara
Created May 5, 2023 22:52
Show Gist options
  • Save booknara/50cceb206197b6ae043b9b881b2eea13 to your computer and use it in GitHub Desktop.
Save booknara/50cceb206197b6ae043b9b881b2eea13 to your computer and use it in GitHub Desktop.
It can be used when a network fetch is running/finishing to respond to ViewModel & UI component (Activity or Fragment)
sealed class BaseResponse<out T> {
data class Success<out T>(val data: T? = null): BaseResponse<T>()
data class Loading(val nothing: Nothing? = null): BaseResponse<Nothing>()
data class Error(val msg: String?): BaseResponse<Nothing>()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment