blockUntilRenderWhen

fun RunScope.blockUntilRenderWhen(timeout: Duration? = section.session.defaults.renderTimeout, condition: () -> Boolean)(source)

Block the current run block until a render has occurred where the passed in condition is true.

This can be useful to do because, due to the threading nature of Kotter (e.g. one thread gets notified, which notifies another, which causes a render to happen on a third), occasionally it's not possible to predict if logic will all execute in one pass or multiple passes. In that case, if you at least know that renders will eventually settle on some consistent output, you can use this method to wait for that.

A very useful pattern is to test the terminal's state:

testSession { terminal ->
section { ... }.run {
// do some stuff and then...
blockUntilRenderWhen {
terminal.resolveRerenders() == listOf(
"expected line 1",
"expected line 2",
"",
)
}
}
}

Parameters

timeout

A timeout to set for this block before it throws a TimeoutCancellationException.