kluck
03/02/2020, 10:28 AMfun childIO() = setState { // -> See <https://github.com/uniflow-kt/uniflow-kt/blob/master/uniflow-core/src/main/kotlin/io/uniflow/core/flow/DataFlow.kt#L93>
onIO { // -> coroutine's IO : suspend fun <T> onIO(block: suspend CoroutineScope.() -> T) = withContext(<http://UniFlowDispatcher.dispatcher.io|UniFlowDispatcher.dispatcher.io>(), block = block)
delay(100)
repository.add("LongTodo")
repository.getAllTodo().mapToTodoListState() // -> fun getAllTodo() : List<Todo>
// -> fun List<Todo>.mapToTodoListState() : TodoListState
}
}
What I'm trying to have is a similar syntax to this, with a setState
taking IO
instead of suspending functions:
fun getAllTodo(): IO<List<Todo>>
fun childIO() = setState { getAllTodo().map { TodoListState(it) } }
Any idea where I should start? I've seen that @Jorge Castillo commented on arrow issues in the uniflow github, maybe he'll know what I'm talking about ^^aballano
03/02/2020, 10:35 AMsuspended()/suspendCancellable()
on it, so you would have
suspended fun getAllTodo(): List<Todo>
kluck
03/02/2020, 10:46 AM