UISwift State access

I'm very new to this, so please forgive me if I'm posting this in the wrong forum or if the answer is incredibly obvious....

I've been learning about @State and @Binding use. In a nutshell, I have been able to successfully create @State variables in my ContentView and create a corresponding @Binding in a component view. My problem is that as I increase the complexity of things, I really want some helper functions to do the work.

To that end, it seems like it would make sense to have these helper functions directly access the @State variables. I get that the component view would need to have a @Binding for any variables that should trigger an update. But the rest, the ones that the component views DON'T need for display, I'd rather have them just be dealt with in the ContentView and helper functions.

I could make global variables and use those, skipping the need to pass them to the component views, but this would give up all the benefits of @State variables being the source of truth and being thread safe.

Is there a good, supported solution for this?

Thanks,

-Verxion

Terms of Service

Privacy Policy

Cookie Policy