there may be a better way of doing this but my specific case I’m defining a sticky dictionary that is a single component that i need to initialize when the snippet is brought onto the canvas. several components will read the initialized value.
If they’re Python components all importing a common library, the library’s setup code will run whichever component imports it first (the objects therein are cached in sys.modules for subsequent components).
I use that pattern together with a launcher to process external config options that apply to all components, and to initialise the logging handlers, before any of the code proper runs.
Generally, I feel component execution order is the Grasshopper user’s prerogative. It’s a bit more complicated with shared state and side effects, but plug-ins should be designed such that given a valid set of inputs, their components will still work correctly, whatever order the user chooses to run them in.
If you yourself are the only user, then I think there’re various events that can be listened too, that can trigger handler functions. But the behaviour of a grasshopper worksheet using such components, starts to get astonishing then.