The incoming vm data sets the Picker as expected, but .onchange is NOT executing. Is this another Apple bug or am I doing this wrong?
import Foundation
import SwiftUI
struct ExamplePicker: View {
@EnvironmentObject var vm: ViewModel
let availableSymbolRates = [
/* band 0 */ ["-","AUTO","1500"],
/* band 1 */ ["-","AUTO","25","33","66","125"],
/* band 2 */ ["-","AUTO","250","333","500"],
/* band 3 */ ["-","AUTO","1000","1500"]
]
var body: some View {
HStack {
Text("Symbol Rate")
Spacer()
Picker("", selection: $vm.response.RxSymbolRate) {
ForEach(availableSymbolRates[vm.response.RxBand], id: \.self) {
Text($0)
}
}
.onChange(of: vm.response.RxSymbolRate, perform: { value in
print("Rx Symbol Rate changed to: \(value)")
vm.request(action: .RXSR, param: value)
})
}
}
}
The double line spacing is a forum bug.