Scenario:
I have a tabbed-based application with parallel network routines of similar function.
Each has has its own network error handler which sends out a @Published alert flag to notify the calling host's alert operator to display the respective alert.
In this case, I have a 'No Internet' alert.
Problem:
Having only one (1) network error routine is okay... but having multiple-network routines creates multiple network errors which either:
- Requires multiple .alert operators (one per tabbed network routine) or
- Use a SINGLE .alert operator for all.
Option #1 is bad because all the .alerts would conflict with one-another on the SAME host.
That leaves option #2.
That would require me to have a GLOBAL alert flag that is shared amongst the parallel alert generators.
These alerts originate in parallel 'observable classes', each containing their network-handling logic (publisher) from which the host can harvest their respective alert messages via @Observed vars.
However, each parallel class CANNOT access the @environment to share a global property which would be shared within ONE single .alert() property on the host struct.
That is my problem.
Note: this is merely a learning application to model different network scenarios; and how to process their respective data subjectively. ...I could simplify this by merely checking the network ONCE vs each tabbed routine.
Question: How can I have various classes share a global var (bool flag & String message) generated by a class vs struct?
Would I need a class singleton and how would that be incorporated within the receiving stuct?
I have two worlds: class & strut that can need to share global data.