Replies: 2 comments
-
I'm confused about why a singleton is needed. Perhaps a small code example of the issue you're facing would help. This example doesn't need to include Cobra, just show the issue you're facing. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Oh, the big thing is that I'm doing a bunch of methods across many different packages each of which could change the display model and states. So rather than passing it as a parameter to every model, i just thought i 'd write a global getter/setter function |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi--
I'm using Cobra command to execute a series of deployments - think something that merges together deploying to GCP, Azure and AWS under a single command.
I am absolutely loving bubble tea - i'm wondering what the right pattern is for maintaining the "model". My initial thought:
In the main cobra command thread, intiialize, and run, the tea program. When it finishes, the application is finished.
Maintain a global singleton of the model - in every sub command/package, etc, provide a function (GetModel()), that gets a pointer to this singleton.
Update that singleton with data as various threads add more information.
Is that standard? Other options - all data update functions are instance functions of the model, or passing around pointers to the model? Am I missing anything?
Beta Was this translation helpful? Give feedback.
All reactions