I don’t know what your definition of “loaded” is. From Rack’s point of view, your module is fully loaded and running when it calls process.
There is no event for when Rack finishes loading all the modules in a patch.
Other modules can be added and removed at any time, so there is no moment when you can say that ‘all the expanders that might be added have been added’. You may have no expanders ever in the lifetime of your module. So, you simply have to deal with the presence or absence of an expander at any time your process is called.
when I first time link a module and expand it, I do some specific tasks
than I save the patch, and store some data on JSON (such the linked module id)
when I reload the patch, the expander call back will be called at some time, but now I want to avoid to redo the task done at point 1 (since its not a user/native linking, but a restoring scenario)
Having the value of linked module id at point 2 is not enough: can’t evaluate if its a preset loading or whole patch loading (context could be different).
So I’m looking for somethings that can flag as a loading patch.
I have no idea, not even sure I understand the question … but maybe this can be used ? (sourcecode on github).
Module: Bogaudio Manual
“MANUAL may be set to output a trigger pulse (the high output voltage for 10ms) on patch load (akin to a Max/Msp loadbang). This is off by default; enable clicking “Trigger on load” on the module’s context (right-click) menu. The pulse is emitted 100ms after the patch starts processing samples.”
If the expander and the host communicate with each other using some kind of messaging protocol (as most do) then the main module can just send a message “who is there”, and look for a returned message that says “I am”.
Of course you need to make all that yourself, or “borrow” it from some other module.