How to know when a UXP plugin is being opened?

I want to run a function automatically when the user Opens the plugin, I can do this the first time it is opened, but is there a way to “listen” when a plugin is being opened again and again?

I did it like this to reload a frame.

var load = 0;
addEventListener('uxpcommand', (event) => {
   const { commandId } = event;
   if (commandId === 'uxpshowpanel' && load == 0) { location.reload(); console.log("reload"); load = 1;}
});

1 Like

Thank you very much Jason, this solved what I was looking for! May I ask how you learned this?

I am sure I found the breadcrumbs somewhere in these forums. It’s been a while so I am not sure exactly.

1 Like

I love this forum, I love being a developer and I love how helpful we are as a community, thank you very much Jason!!

2 Likes