I’m implementing a common theme chooser for some modules. Ideally when a user changes to a new theme I want all instances of modules within my plugin to also change. I wonder if there is a preferred way to do it. Here are the two options I’ve considered:
Each module regularly reads the .json file associated with the plugin and detects if the theme changes. I don’t like this because it feels like a lot of useless disk access and I don’t want to do it very often for this reason.
Try to find modules that are of the correct type and send them some kind of signal. I noticed that the engine offers access to other modules by their ID but not any kind of iterator. Most of the IDs are small numbers but I assume this isn’t guaranteed. (they could just be random UIDs?) I could just scan the first n module IDs to see if they exist and are of my type… but this also feels wrong.
What is the correct way to send signals to other modules of a specific plugin type to cause them to perform some action. I don’t care if they just go and read the theme JSON file again… I just want to avoid them polling it.