Not sure how best to start a network fetch in a specific case in my SwiftUI code

I have a button in my swiftUI view that allows users to open a datePicker and then use the selected date to start a network fetch.

The date picker is presented using this code:
Code Block
        .sheet(isPresented: $showDatePicker) {
            ModalDatePicker(startDate: self.podcast.earliestDate,
                            endDate: self.podcast.latestDate,
                            currentDate: self.$datePickerDate,
                            isShowing: self.$showDatePicker,
                            doneTapped: self.$dateSelected)
        }

My plan is to use dateSelected to know when the user taps Done rather than cancelling.

But I'm not sure where I need to check dateSelected.
My first thought was in the body method.
Code Block
if dateSelected {
dateSelected = false
startFetch()
}

But that doesn't seem to compile, and frankly feels wrong.

I also thought of doing this in ModalDatePicker, but that also feels wrong.
I'm guessing the solution will involve combine and perhaps a publisher, but I don't yet understand how to implement this.
Any assistance would be appreciated.
Thanks,
Mike

My current plan is to replace dateSelected with a roll your own binding

Code Block
let binding: Binding<Bool>: {
return Binding<Bool>(
get: {
return false
},
set: {
if $0 {
startFetch()
})

Doesn't feel great, but it appears to work


Not sure how best to start a network fetch in a specific case in my SwiftUI code
 
 
Q