setInterval

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

midiway
Posts: 2
Joined: Wed Oct 26, 2016 10:25 pm

setInterval

Post by midiway »

I need to do a task every N seconds, so I need something like setInterval as we do have in standard browsers.
Tried the following:

Code: Select all

$.setTimeout = function(func, time) {
while(true)
{
$.sleep(time);
func();
}
};
but

Code: Select all

$.sleep(time);
block the UI, as it is synchronous..

any alternative?
JavierAroche
Posts: 29
Joined: Sat Jul 30, 2016 3:52 am
Location: San Francisco

Re: setInterval

Post by JavierAroche »

Other than sleep (which is really not ideal), I don't think you can set a timeout in a pure JSX context. If you're in the context of an HTML panel or Generator, then you have way more flexibility to do something like this.