SuasDynamicEquatable

public protocol SuasDynamicEquatable

Protocol used by EqualsFilter filter callback to compare two state values. If your state implements the Equatable protocol there is no code required to implement SuasDynamicEquatable

Example

Implement SuasDynamicEquatable manually

struct MyState: SuasDynamicEquatable {
  let value: Int

  func isEqual(to other: Any) -> Bool {
    // Cast to same type
    guard let other = other as? MyState else { return false }

    // Compare values
    return other.value == self.value
  }
}

Implementing SuasDynamicEquatable as an extension

If your type implement equatable

struct MyState: Equatable {
  let value: Int
  static func ==(lhs: MyState, rhs: MyState) -> Bool { ... }
}

You dont need to implement SuasDynamicEquatable just add it as an extension to MyState. No extra code needed.

extension MyState: SuasDynamicEquatable { }
  • isEqual(to:) Default implementation

    Undocumented

    Default Implementation

    Undocumented

    Declaration

    Swift

    public protocol SuasDynamicEquatable