(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| // Result is a superpowered enum that can be Success or Failure | |
| // and the basis for a railway junction | |
| sealed class Result<T> | |
| data class Success<T>(val value: T): Result<T>() | |
| data class Failure<T>(val errorMessage: String): Result<T>() | |
| // Composition: apply a function f to Success results | |
| infix fun <T,U> Result<T>.then(f: (T) -> Result<U>) = | |
| when (this) { | |
| is Success -> f(this.value) |