onSuccess

fun <T> State<T>.onSuccess(block: @Composable (T) -> Unit)

Executes the given composable block if the State is State.Success. The block will receive the data from the State.Success as its parameter.

This is a convenience function to simplify conditional rendering based on the state.

Example usage:

val myState: State<String> = ... // Assume this is State.Success("Hello")

myState.onSuccess { data ->
Text("Data loaded: $data")
}

Parameters

block

The composable block to execute if the state is Success. The data of the success state will be passed to this block.