kluck
04/30/2019, 9:41 AMdelay
doesn't want to compile without a first arg being a CoroutineContext, so is this version correct:
fun <Type> IO<Type>.useCase(ok: (Type) -> Unit, error: (Throwable) -> Unit): IO<Unit> =
defer(<http://Dispatchers.IO|Dispatchers.IO>) { this@useCase }
.flatMap { t -> delay(Dispatchers.Main) { ok(t) } }
.handleErrorWith { err -> delay(Dispatchers.Main) { error(err) } }