PurchaseState

sealed class PurchaseState

A sealed class representing the different states of a purchase operation.

This class is designed to be used as UI state.

By using a sealed class, we can ensure that all possible states of the purchase flow (Loading, Success, Error) are handled exhaustively in a when expression, which prevents runtime errors and makes the UI logic more robust.

The class is marked as Stable to inform the Compose compiler that the type is stable. This is a performance optimization, as it allows Compose to skip recomposing composables that take this state as a parameter if the instance has not changed.

Inheritors

Types

Link copied to clipboard
data class Error(val exception: Exception) : PurchaseState

Represents the state where the purchase operation has failed.

Link copied to clipboard
data object Loading : PurchaseState

Represents the state where the purchase operation is in progress.

Link copied to clipboard
data class Success(val successfulPurchase: SuccessfulPurchase) : PurchaseState

Represents the state where the purchase has completed successfully.