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.