Last active
November 28, 2018 00:06
-
-
Save jbrunton/291f96890a24c4fb079bb85d39e5b684 to your computer and use it in GitHub Desktop.
AsyncResult Simple Example
This file contains 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
val result: AsyncResult<MyData> = // ... | |
val viewState = result | |
.map { MyViewState.from(it) } | |
.onError(IOException::class) { | |
map { | |
if (cachedValue == null) { | |
failure(NoConnectionViewState) | |
} else { | |
success(cachedValue) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment