@Stu's answer works well with me, I made it as a modifier for easier usage.
extension View {
func refreshablePersistent(_ operation: @escaping () async -> Void) -> some View {
self
.refreshable {
await Task {
await operation()
}.value
}
}
}
The issue I'm having in my case is that viewModel.load()
update viewState
which @Published
to show a loading indicator, That causes a redraw -> task cancelled :)
also load has many request made consecutively, each updates the ui.
Idk but if I understand it well I shouldn't update the ui until all requests are finished. Can be implemented but needs a lot of fining.