Hi all, my question surrounds the proper way to handle data between views, view managers, and sub-views.
Essentially my app is currently comprised of an “overall” view, which displays one of two views based on a “loggedIn” bool. One of these views is a tabview and the other can present two sheets based on button presses.
Currently these views get their data from higher views or create it themselves and the functions that manipulate that data are in the same view struct. What I’d like to happen, and what I think the proper way to do things, is move all those values and methods to an external view-model. Then I can initialize them and as the user moves through the app those values can change and then be referenced whenever needed.
How can this be done so that any view, regardless of position within the view-hagiarchy, can access and use this view-model class (or struct?) Also if a lower view changes a value such as “loggedIn” to false within the view-model, can higher views recognize that somehow and log the user out? (aka change the view)
Hopefully this makes sense, I would have copied some of my code in here but I don’t think any one part displays my issue. Thank you for reading through!