onFailure

Executes the given composable block if the State is State.Failure. The Throwable associated with the failure is passed to the block.

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

Example usage:

val myState: State<String> = ...

myState.onFailure { error ->
Text("An error occurred: ${error.message}")
}

Parameters

block

The composable block to execute if the state is Failure. The Throwable that caused the failure is provided as an argument.