EnvironmentObject update timeliness

My ContentView has an @EnvironmentObject and a few @State var's.
The State vars are for use in TextFields, one can use a Picker or manual entry, and works fine.
The other State var is to have its value set when the user hits a Button whose action executes a host of functions that changes the values of over twenty @Published vars monitored/updated by the @EnvironmentObject vis-a-vis Combine. This TexField must also be manually set/edited when desired. Within that same Button(action:{}) the next line of code attempts to set a State var to the value of the Published EnvironmentObject that had been changed by all those functions in the previous line.
The problem is: the EnvironmentObject is not updated by the time this line of code is executed. Such that the Button must be pressed twice for the result to change the TextField.
I have scoured the web and did not find, or did not understand, what is amiss.

I have successfully used .id(UUID()) on Views to ensure updates, but this issue is within a Button/action and I wouldn't know how to implement it here as TextField is a struct, and I can't implement a View.id(UUID()) inside the Button. So far as I know.

Thanks.

Accepted Reply

The culprit was Dispatch code that asynchronously changed my Published var. When I removed Dispatch, I got the results I expected.

Replies

The culprit was Dispatch code that asynchronously changed my Published var. When I removed Dispatch, I got the results I expected.