<@U0C32LHG9>: I think the best way is by using a ...
# kovenant
m
@n3o59hf: I think the best way is by using a separate
Context
for io since that tends to block, so something like this:
Copy code
val ioContext = Kovenant.createContext {
    workerContext.dispatcher = buildDispatcher {
        concurrentTasks = 2 //whatever you prefer
    }
    //Use the default one
    callbackContext.dispatcher = Kovenant.context.callbackContext.dispatcher
}

fun <V> ioTask(body: () -> V) : Promise<V, Exception> {
    //execute the task on the io threads
    val promise = task(ioContext, body)

    //use default context for the rest of the work
    return promise.withContext(Kovenant.context)
}

fun main(args: Array<String>) {
    ioTask {
        File("path/to/file").readText()
    } then {
        it.replace(":)", "☺")
    } success {
        println(it)
    }
}