The behavior of EditButton/EditMode is killing me.
I have a model updating in the background and fetching data from a server every 15 seconds. Several Views are dependent on the updating result.
And now I want to stop auto-updating when the edit mode is active.
So I have code like this:
@Environment(\.editMode) var editMode
var body: some View {
SomeView{
// somewhere in the view hierarchy there is an EditButton
}
.onChange(of: editMode!.wrappedValue){
if $0.isEditing {
model.stopAutoUpdate()
} else {
model.startAutoUpdate()
}
}
And here come the weird things:
- Every time the model updates, the onChange part gets called.
- When I tap the edit/done button, nothing gets called even though the List items have the right performance.
I am completely no idea why it behaves like that. Someone please help me.