repository-resource-flow-pattern
Installation
SKILL.md
A result envelope for repository flows
The envelope types live in the domain module beside the repository interfaces that return them, so both implementation and caller
name them without depending on each other (clean-arch-kmp-readiness). Three of them, because three different things happen at a repository boundary:
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)
}
sealed class LocalResource<T>(val data: T? = null, val message: String? = null) {
class Success<T>(data: T) : LocalResource<T>(data)
class Error<T>(message: String, data: T? = null) : LocalResource<T>(data, message)
class Loading<T> : LocalResource<T>()
}