onActionExecution

fun onActionExecution(interceptor: suspend (action: Any, next: suspend () -> Unit) -> Unit)(source)

Add an async interceptor that wraps the action's suspend execution. Runs inside the coroutine — next() suspends until the action completes.

actor.onActionExecution { action, next ->
val start = System.nanoTime()
next() // suspends until the action finishes
val ms = (System.nanoTime() - start) / 1_000_000
println("${action::class.simpleName} took ${ms}ms")
}