I am attempting to update the UI of my panel via JS after the user clicks a button (disable button, update progress bar, enable button at the end) but all the UI updates appear to be blocked by the JS code until it completes.
I have tried to run executeAsModal but i cannot get that to run properly. What am i missing, it should be possible to use JS to update the UI elements while I am processing the document/layers, right?
Do I have to use API v2? How do i do that? Is the executeAsModal inline or outside my function?
I’m just guessing here, but using .then should be non-blocking await holds execution of the following lines until the promise is resolved/rejected while then/catch should in theory act as a callback without blocking execution
Its not gated by the async/await code - it does it even with simple logic. I cant seem to update the UI while the JS code is running. This makes it so that buttons cant be disabled and new elements shown - its quite limiting.
Can you break your code in to multiple “await” calls? This should allow you to insert and update the UI wherever you’d like between the batchPlay/API calls. Another option might be to update the UI before calling any batchplay/APIs. I’ve noticed that if UI updates are placed after “await” calls, they execute after the “await”. But UI updates can also be placed before or in between “await” calls, and then execute in that sequence.
I found a way to solve the problem (or at least work around it) by making a number of different changes - updating the manifest to v5, updating the API to v2, using executeAsModal to make the required changes to the document and to provide a progress bar.
Disabling the buttons still didn’t properly work even with async/await. It isn’t clear to me how (or even if) UI updating is (properly) supported from JS code, but it works well enough for now.