Custom module EDIT on init timing issue

leaving a note here incase anyone is following after...

I've been fiddling around trying to get label changes working via /EDIT on init function of Custom Module.

Took a while to work because it was silently failing.

Prognosis is that the EDIT was being received before the targets were loaded, so the message was firing and landing nowhere.

Solution was to add a timer to delay the messages 800ms. Very inelegant, but there we go, it works.

There is a reliable way to do it:

app.on('sessionOpened', function(data, client) {
    // event triggered when a client finished loading a session

    receive('/EDIT', 'widget_id',
        {label: 'foo'}, // overwrite some properties
        {noWarning: true}, // (optional) prevent "unsaved changes prompt"
        {clientId: client.id} // (recommended) send command only to the client that just connected 
    )

})

module.exports = {
  // init, oscInFilter, etc
}
1 Like

ah much nicer. thank you!