Monitor as a Singleton? #20
-
Brad I want to have a single instance of the Monitor class feeding events to n number of other classes running in there own threads. I'm considering wrapping the Monitor in a Singleton class. So,
TIA Kevin |
Beta Was this translation helpful? Give feedback.
Answered by
braddwalker
Feb 12, 2021
Replies: 1 comment 2 replies
-
@ruffk that's a great catch -- it really should be a singleton and not transient. I really can't think of a usecase for needing multiple instances of the Monitor class itself. You should be able to instantiate it as a singleton, inject it into any classes/threads, and have the various consumers all just hook into the event listeners. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
braddwalker
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ruffk that's a great catch -- it really should be a singleton and not transient. I really can't think of a usecase for needing multiple instances of the Monitor class itself. You should be able to instantiate it as a singleton, inject it into any classes/threads, and have the various consumers all just hook into the event listeners.