Reputation: 8599
I am trying to use distinctUntilChanged
with combineLatest, eg:
Observable.combineLatest(focusedCourse, infoState)
.distinctUntilChanged()
.map { focusedCourse, infoState in
// Implementation
}
.bind(to: videoSource)
.disposed(by: bag)
However I am getting the error:
Type '(BehaviorRelay<Course?>.Element, BehaviorRelay<InfoState>.Element)' cannot conform to 'Equatable'
I have conformed both Course
and InfoState
to equatable but still get this error. How can I fix this?
Upvotes: 1
Views: 1886
Reputation: 1242
I don't think a tuple conforms to Equatable even if all its elements do so you have to provide the equality check to distinctUntilChanged
:
Observable.combineLatest(focusedCourse, infoState)
.distinctUntilChanged { $0 == $1 }
.map { focusedCourse, infoState in
// Implementation
}
.bind(to: videoSource)
.disposed(by: bag)
Upvotes: 1