Skip to content
This repository has been archived by the owner. It is now read-only.
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle
sealedapiresults-retrofit-rx
sealedapiresults-retrofit
sealedapiresults
.gitignore
LICENSE
README.md
build.gradle
dependencies.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

SealedApiResults

Download

SealedApiResults has been archived in favor of HttpMonads.

SealedApiResults utilizes Kotlin's sealed classes to provide a safe way of handling http network calls.

Example

fun onResult(result: SealedApiResult<String>) =
    when(result) {
      is Ok200 -> println(result.body)
      is Unauthorized401 -> println("Unauthorized")
      is Some -> println("Unhandled response: ${result.code}")
      is NetworkError -> result.e.printStackTrace()
    }

The compiler will complain when you forget to handle a case, such as the NetworkError. This makes for a very safe way of dealing with network results.

Install

SealedApiResults is available on JCenter. For Gradle users, add the one of the following 'compile' sections to your build.gradle:

repositories {
    jcenter()
}
dependencies {
    compile "com.nhaarman:sealedapiresults:x.x.x"
    compile "com.nhaarman:sealedapiresults-retrofit:x.x.x"
    compile "com.nhaarman:sealedapiresults-retrofit-rx:x.x.x"
}
You can’t perform that action at this time.