iex
04/08/2020, 5:23 PMsealed class VoidOperationState {
object Progress: VoidOperationState()
object Success: VoidOperationState()
data class Failure(val t: Throwable): VoidOperationState()
}
sealed class OperationState<out T> {
object Progress: OperationState<Nothing>()
data class Success<out T>(val data: T): OperationState<T>()
data class Failure(val t: Throwable): OperationState<Nothing>()
}
(Of course I could make VoidOperationState just an OperationState<Unit> but that's not nice, since I'd have to be always passing the Unit to Success...Zach Klippenstein (he/him) [MOD]
04/08/2020, 5:26 PMUnit.Zach Klippenstein (he/him) [MOD]
04/08/2020, 5:31 PMSuccess that takes no arguments and returns Success(Unit) to get rid of the boilerplate.iex
04/08/2020, 9:51 PMUnit isn't so badiex
04/08/2020, 9:51 PM