Slide 62
Slide 62 text
interface TodoServices {
fun calculateProgress(todos: List): Triple {
val nrOfDone = todos.count { it.done }
val nrOfTotal = todos.count()
return Triple(nrOfDone, nrOfTotal, nrOfDone / nrOfTotal.toFloat())
}
}
interface GetTodos : TodoGateway, TodoServices {
fun getTodos(): Single = get().map {
with(calculateProgress(it)) {
GetTodosResult(
it,
this.first,
this.second,
this.third
)
}
}
} data class Todo(val id: Long, val description: String, val done: Boolean)