arduino-create-agent icon indicating copy to clipboard operation
arduino-create-agent copied to clipboard

Remove global clients

Open dido18 opened this issue 9 months ago • 5 comments
trafficstars

Please check if the PR fulfills these requirements

  • [ ] The PR has no duplicates (please search among the Pull Requests before creating one)
  • [ ] Tests for the changes have been added (for bug fixes / features)
  • What kind of change does this PR introduce? The purpose of this PR is to improve the maintainability, testability, and clarity of the codebase by removing global variables and explicitly passing dependencies as arguments to functions or methods. Global variables can lead to tightly coupled code, making it harder to understand, test, and maintain.
  • What is the current behavior?
  • What is the new behavior?
  1. remove global variables, they are now created in the main function and passed explicitly to the components or functions that need them.

    • Tools *tools.Tools
    • Systray systray.Systray
    • Index *index.Resource
    • h = hub
    • loggerWs logWriter
    • serialPorts SerialPortList
    • sh = serialhub
  2. move the go hub.serialPortList.Run() from the maingo into the hub.run() because the hub is in charge of connecting serial events to websocket clients.

  • Does this PR introduce a breaking change? No.
  • Other information:

dido18 avatar Jan 27 '25 13:01 dido18