runOn
inline suspend fun <T : S> runOn(crossinline predicate: (T) -> Boolean = { true }, crossinline block: suspend SubStateSyntax<S, SE, T>.() -> Unit)(source)
This API is intended to simplify and add type-safety to working with sealed class states.
Executes the given block only if the current state is of the given subtype and the given predicate matches.
The block will be cancelled as soon as the state changes to a different type or the predicate does not return true. Note that this does not guarantee the operation in the block is atomic.
The state is captured and does not change within this block.
Parameters
predicate
optional predicate to match the state against. Defaults to true.