[Solved] Values being lost while waiting for fragment to load

I am receiving multiple OSC messages, the first of which determines which fragment to load and then all the values of the fragment's widgets (could be hundreds of values). However by the time the fragment has loaded, the values have all been sent and the loaded fragment widgets are not updated. I need some way to store the values and update the fragment widgets after it has loaded. What would be the options to deal with this?

Without using fragments, I have all the different panels in tabs and dynamically switch tabs. Which works, but I don't want to load thousands of widgets if they're not getting used.

Thanks.

I think of 3 possibilities:

  • add some delay after the message that loads the fragment to ensure it's loaded when the values arrive
  • with a custom module, preload all fragments when the session loads (in a callback bound with app.on('sessionOpened', callback) ): loop over the fragment file names in a custom module and send them to a fragment widget. You can empty the fragment afterwards, the fragment files will be kept in memory.
  • put a script in the fragment that sends a message when created to indicate the other software that it's ready to receive values.

Thank you Jean-emmanual for your reply.

I realised that I had an address wrong. Corrected, fragment widgets seem to be loading and updating values correctly.

Before realising the address was wrong, I solved this by creating a "database" using a matrix of variables each containing an OSC listener and then "queried" the database using linkId's. It worked great, even if the whole exercise was unnecessary.