Last active
June 14, 2018 13:19
-
-
Save marcinOz/0920e414d3da5e4e31cd95ad2a9779a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class ResourceState<T> | |
class LoadingState<T> : ResourceState<T>() { | |
override fun hashCode(): Int = javaClass.hashCode() | |
override fun equals(other: Any?) = equalz(other) | |
} | |
class EmptyState<T> : ResourceState<T>() { | |
override fun hashCode(): Int = javaClass.hashCode() | |
override fun equals(other: Any?) = equalz(other) | |
} | |
data class PopulatedState<T>(val data: T) : ResourceState<T>() | |
data class ErrorState<T>(val message: String?) : ResourceState<T>() | |
inline fun <reified T : ResourceState<*>> T.equalz(other: Any?) = when { | |
this === other -> true | |
other !is T -> false | |
else -> true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment