onCompletion

fun onCompletion(block: (finalStateName: String) -> Unit)(source)

Run block when the statechart reaches any final state (just after the chart has stopped). The block receives the name of the final state reached. A natural place to install and start a different statechart on the owner (agent.useStatechart(next)), send a completion message, or record a result — the chart is already stopped, so isStarted is false and a replacement may be selected.