Thunkable Execution Model: "ABC" != "ABC"

These blocks:

cause “ABC does not equal ABC” to be placed in Label2. The previous “set” doesn’t complete before the if is evaluated.

Please see more details and thoughts on Thunkable’s execution model in this Google doc:

2 Likes

We’ll fix this so ABC == ABC (it’s a bug). Thanks for the detailed explanation.

3 Likes

Thanks, Paul. Can you also send me a short description of how the model works-- I want to explain that in the book I’m working on

Ok, ‘ABC’ === ‘ABC’ now.
https://x.thunkable.com/copy/7efdb89ef32b41644a87f12309ee1fba

Events will run uninterrupted until you reach a block that takes time to execute. While waiting for that block to execute, other events may run.

The user interface isn’t updated until a particular event handler completes or until there is a block that takes time to execute (whichever comes first).

Examples of blocks that take time to execute include (but are not limited to) the wait block, set/get/change stored and cloud variables.

An example of events running at the same time:
https://x.thunkable.com/copy/9e4e61a44dd19a03b8371c243d6bf6a5

2 Likes

Thanks, Paul, for the fix and the explanation.

I’m not sure I understand the example you sent for two events running at “same time”.

  1. I didn’t know you could have two event handlers for the same event, as in the sample (both are Button1.Click).
  2. I’m assuming that if there was a second handler with a different event, that one could run interleaved as well.
  3. Just to be certain, In the sample you sent, to test it I click the button a second time within .5 seconds and that causes the second Button1.Click event handler to run?

Thanks again,

Dave

  1. Yes, you can have two event handlers for the same event.
  2. Yes, a second handler for a different event will run interleaved (following the same rules I described in my earlier post).
  3. No, I was sending the example so that you could click the button just once.

When the button is tapped (just once) both events run. The background color of the button and screen change (“simultaneously”). Then after 0.5 seconds, the background color of the button changes. Lastly 0.5 seconds later the button and screen’s background color both change (“simultaneously”).


If you want a javascript analogy, think of the event handlers as calling Button1.addEventListener('Click', () => {change the colors...}). If you add multiple listeners, then the multiple callback functions will be called.

This is an old thread, but I’ve had trouble several times recently with needing to add a wait block to make a piece of code work OK. Paul, you said that the user interface isn’t updated right away - are there other things that don’t update right away as well that thunkers should watch out for? I get the sense that variables in loops are sometimes also wonky?