How do you get automatic Equable conformance for an enum with a closure in Swift?

140 views Asked by At

I have an enum that has several cases with associated values and it conforms to Equatable.

I now need to add another case that uses a closure for its associated value and was wandering how I could make it conform to Equatable without having to write out the custom Equatable conformance.

For example say I had an enum like below

enum CoordinatorAction: Equatable {
    case closed
    case goToHome(isSignedIn: Bool)
    case addedItem(_ itemID: String)
    case removedItem(_ itemID: String)
}

How could I then add the didSuccessfulyAddItem enum with A closure whilst still having automatic conformance to equatable without getting a compile error?

enum CoordinatorAction: Equatable {
    case closed
    case goToHome(isSignedIn: Bool)
    case addedItem(_ itemID: String)
    case removedItem(_ itemID: String)
    case didSuccessfulyAddItem(_ callback: (Bool) -> Void)
}

Thanks

0

There are 0 answers