Discuss Scratch

randsk
New to Scratch
7 posts

Asynchronous get_status?

Hi,

i have some code working now that uses some “blocks that wait” - the do some async code: https://github.com/LLK/scratchx/wiki#command-blocks-that-wait

With these blocks you can kick off some work (web socket, ajax etc) and then invoke a ‘callback’ to tell scratch you're done (and to move onto the next block etc)

I need a similar kind of approach for the get_status function, however this seems very much synchronous. I could implement the function synchronously myself, but i'm worried about locking up the scratch UI.

Any thoughts please?
MegaApuTurkUltra
Scratcher
1000+ posts

Asynchronous get_status?

randsk wrote:

Hi,

i have some code working now that uses some “blocks that wait” - the do some async code: https://github.com/LLK/scratchx/wiki#command-blocks-that-wait

With these blocks you can kick off some work (web socket, ajax etc) and then invoke a ‘callback’ to tell scratch you're done (and to move onto the next block etc)

I need a similar kind of approach for the get_status function, however this seems very much synchronous. I could implement the function synchronously myself, but i'm worried about locking up the scratch UI.

Any thoughts please?
What is your extension doing on get_status that takes so long?

You could try doing the work in the background and returning a cached value on get_status

$(".box-head")[0].textContent = "committing AT crimes since $whenever"
randsk
New to Scratch
7 posts

Asynchronous get_status?

That's not a bad idea, thanks.

Same as my last post you replied to - I need to talk to a companion app to issue commands. However I want to make sure everything remains responsive if the app is down, or the device it controls is not connected yet.

Cheers
MegaApuTurkUltra
Scratcher
1000+ posts

Asynchronous get_status?

randsk wrote:

That's not a bad idea, thanks.

Same as my last post you replied to - I need to talk to a companion app to issue commands. However I want to make sure everything remains responsive if the app is down, or the device it controls is not connected yet.

Cheers
Well then just constantly ping the app every 10 seconds or so, and if it's down then start returning a not ready status.

$(".box-head")[0].textContent = "committing AT crimes since $whenever"
PenguinLover1123
Scratcher
1000+ posts

Asynchronous get_status?

Bumper

Good morning/afternoon/night
TurtleLegos
Scratcher
1000+ posts

Asynchronous get_status?

PenguinLover1123 wrote:

Bumper
Dude, this is the third topic in a row. The OP is inactive.

BE DRY, MOIST IS TOO MOIST

hey im back! march 3 2024

Powered by DjangoBB