Open
Description
final class ViewModel {
let nodes = CurrentValueSubject<[Int], Never>([])
var cancel: AnyCancellable?
init() {
cancel = nodes
.dropFirst()
.filter {
!$0.isEmpty
}
.withLatestFrom(nodes)
.sink { [weak self] nodes in
guard let self else { return }
print("nodes.count: \(nodes.count)")
print("self.nodes.value.count: \(self.nodes.value.count)")
if nodes.count != self.nodes.value.count {
print("WTF")
}
}
nodes.send([1, 2, 3])
}
}
If you run it multiple times, it might print WTF
. I've used the Rx framework for many years and I find this behavior quite strange. Is this normal or abnormal?
Metadata
Metadata
Assignees
Labels
No labels