collectWhileInState

fun <T> collectWhileInState(flow: Flow<T>, executionPolicy: ExecutionPolicy = ExecutionPolicy.ORDERED, handler: suspend (item: T, state: State<InputState>) -> ChangedState<S>)

Triggers every time the state machine enters this state. The passed flow will be collected and any emission will be passed to handler.

The collection as well as any ongoing handler is cancelled when leaving this state.

executionPolicy is used to determine the behavior when a new emission from flow arrives before the previous handler invocation completed. By default ExecutionPolicy.ORDERED is applied.


fun <T> collectWhileInState(flowBuilder: (InputState) -> Flow<T>, executionPolicy: ExecutionPolicy = ExecutionPolicy.ORDERED, handler: suspend (item: T, state: State<InputState>) -> ChangedState<S>)

Triggers every time the state machine enters this state. The passed Flow created by flowBuilder will be collected and any emission will be passed to handler.

The collection as well as any ongoing handler is cancelled when leaving this state.

executionPolicy is used to determine the behavior when a new emission from Flow arrives before the previous handler invocation completed. By default ExecutionPolicy.ORDERED is applied.