async

protected fun <T> async(block: suspend () -> T, reducer: State.(Result<T>) -> State)(source)

Executes a suspend operation on IO and reduces the result into state.

Example

async(
block = { repository.getItems() }
) { result ->
result.onSuccess { items ->
copy(items = items)
}
}