I am trying to run a function after a user has selected a picker option.
The idea is that the user can set a default station, so I need to be able to send the selected value to a function so I can save it inside the core data module. How can I achieve this?
import SwiftUI
struct SettingsView: View {
    var frameworks = ["DRN1", "DRN1 Hits", "DRN1 United", "DRN1 Life"]
    @State private var selectedFrameworkIndex = 0
    
    func doSomethingWith(value: String) {
        print(value)
    }
    
    var body: some View {
        NavigationView {
            Form {
                Section {
                    Picker(selection: $selectedFrameworkIndex, label: Text("Favorite Station")) {
                        ForEach(0 ..< frameworks.count) {
                            Text(self.frameworks[$0])
                        }
                    }.onReceive([self.frameworks].publisher.first()) { value in
                        self.doSomethingWith(value: value)
                    }
                }
            }
            .navigationBarTitle("Settings")
        }
    }
}