I’ve this code:
import SwiftUI
import Mix
closing class ViewModel: ObservableObject {
@Printed var textual content = ""
var cancellables = Set<AnyCancellable>()
init() {
$textual content
.sink { completion in
} receiveValue: { textual content in
print("Textual content (textual content)")
}.retailer(in: &cancellables)
}
}
struct ContentView: View {
@StateObject non-public var vm = ViewModel()
var physique: some View {
TextField("Title", textual content: $vm.textual content)
}
}
#Preview {
ContentView()
}
What I’ve observed, if I sort one letter, i obtain two values.
So at first it would simply say Textual content
. And if I sort one letter, say letter A, output will seem like this:
Textual content A
Textual content A
In some circumstances I noticed it prints identical worth much more than two occasions.
I do know I can use removeDuplicates
however why is that this really taking place?