Skip to content

Instantly share code, notes, and snippets.

@tahaak67
Created February 8, 2023 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tahaak67/2fb297ed77ee18a791c4f51783b9af51 to your computer and use it in GitHub Desktop.
Save tahaak67/2fb297ed77ee18a791c4f51783b9af51 to your computer and use it in GitHub Desktop.
Resource wraper class with Success, Error and Loading states.
/**
* Created by Taha Ben Ashur (https://github.com/tahaak67) on 08,Feb,2023
*/
sealed class Resource<T>(
val data: T? = null,
val message: String? = null
) {
class Success<T>(data: T) : Resource<T>(data)
class Error<T>(message: String, data: T? = null) : Resource<T>(data, message)
class Loading<T> : Resource<T>()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment