Given the following example:
enum ViewState {
case idle
case loading
case caseWithAssociatedValue(String)
}
class View {
private var state: ViewState = .idle
func setState(to state: ViewState) {
guard state != self.state else { return }
self.state = state
}
}
I can't compare two properties of type ViewState and I can't use a raw value to compare as one of my cases has an associated value.
What I'm looking for is a way to check if the new value for state a new value or the same as the current value. Is this possible?