I have been working on converting code from RxSwift to Swift Concurrency since last week and have successfully transitioned some parts. However, I am currently looking for a way to replace the distinctUntilChanged operator defined in RxSwift with an equivalent in Swift Concurrency.
Yesterday, I came across this library and am curious to know if it offers a suitable replacement for the distinctUntilChanged operator.
Could anyone advise how I might achieve this using this library? Any suggestions would be greatly appreciated.
For your reference, here is the code snippet where I'm using the distinctUntilChanged operator that I would like to replace:
// *The code below is just an example.
Observable
.combineLatest(APIRequest1(), APIRequest2())
.distinctUntilChanged { old, new -> Bool in
let (oldResponse1Tuple, oldResponse2Tuple) = old
let (newResponse1Tuple, newResponse2Tuple) = new
let oldResponse1: [CustomType] = oldResponse1Tuple.0
let oldResponse2: [CustomType] = oldResponse2Tuple.0
let newResponse1: [CustomType] = newResponse1Tuple.0
let newResponse2: [CustomType] = newResponse2Tuple.0
return (oldResponse1 == newResponse1) && (oldResponse2 == newResponse2)
}
.subscribe(onNext: { [weak self] in
//...
})
.disposed(by: disposeBag)
Hello,
I have been working on converting code from RxSwift to Swift Concurrency since last week and have successfully transitioned some parts. However, I am currently looking for a way to replace the distinctUntilChanged operator defined in RxSwift with an equivalent in Swift Concurrency.
Yesterday, I came across this library and am curious to know if it offers a suitable replacement for the distinctUntilChanged operator.
Could anyone advise how I might achieve this using this library? Any suggestions would be greatly appreciated.
For your reference, here is the code snippet where I'm using the distinctUntilChanged operator that I would like to replace: