Is there any way to interrupt a workerscript?

Again as per title, there doesn’t seem to be any way to communicate to a worker that their service is no longer required, so if you need say 1000 sync xhr’s the worker will happily take 2-3 minutes to finish, if in that time user navigates back and again onto a page that requires worker they will have to wait 2-3 minutes before the task is replaced as the worker still finishes the old task. The only way I found is adding extra 1000 xhrs to a local file and updating that from say 0 to 1 so that worker checks everytime if their service is still needed, but that of course makes the original task twice as heavy/long (not to mention memory wear and tear). Sharing a listmodel with a worker doesn’t seem to work as it gets it once at start and can’t sync it to it (or rather it’s not synced to worker). Any ideas?

I have had some success using an Instantiator (in my case it’s WebSockets not XHRs, but the use case is similar):

Setting its model should destroy all previously created objects.
Not sure that will apply to running WorkerScripts though.

1 Like

Hmm. In tooter the worker script is only called on a timer in the main view to refresh threads (home timeline, federated, bookmarks, etc). Since there are several, the timer is distributed/offset for each uri. It’s not really ideal, but it means the worker script ‘returns’ and exits till it’s called again.