Open randyzwitch opened 6 years ago
Per Slack
Randy Zwitch [3:37 PM]
is there a recommended way to have a global settings object for a package?
that users can update
for example, for a plotting package, allowing a user to set that the rendering should be 500x300px, canvas rendered, with black and white theme (where keys are package specific of course)
David Sanders [3:43 PM]
I think the most recommended way would be to have a Settings struct, and pass around the instance to all relevant functions.
Randy Zwitch [3:46 PM]
would I have to worry about doing `deepcopy()` or similar? I’m thinking that if I changed the global settings, I would only want them to apply going forward
meaning, I re-ran a function to get its output
Chris Rackauckas [4:35 PM]
Or use environment variables.
Chris Rackauckas [4:35 PM]
Or use environment variables in an init function to build a settings struct.
Thinking about creating a global for settings such as size, theme, display type, etc.