Note: I also reported this on GitHub: Screen Opens and Screen Starts both trigger when a screen is displayed · Issue #912 · thunkable/thunkable-issues · GitHub
I thought I was pretty clear on the difference between a “Screen Starts” event and a “Screen Opens” event…
Screen Starts = when a screen is first displayed
Screen Opens = every time a screen is displayed
But an app I’m developing isn’t responding that way. It seems like Starts & Opens are both triggering whenever I navigate back to the original screen.
So I made a simple demo in the legacy interface that shows the problem:
https://x.thunkable.com/copy/70887ca4919c64919b966bfad095e774
These event blocks should not both be firing when the first screen is navigated to again:
If I press Next, Back, Next, Back, etc. to switch between screens, I end up with an equal count:
I would expect the Starts value to remain at 1 unless I re-launched the app.
3 Likes
@tatiang
I tested this previously and I believe Thunkable actually creates an instance of the screen every time you use the screen and therefore any time you go to the screen, you are not technically (programmatically) going back to the screen but rather creating a new screen object and importing the content of the previous screen to the newly created one and this is the reason you have the starts
event fired every time.
However, when you encapsulate a group of screens inside a navigator, the expected behaviour becomes active and the screen starts
event will fire once but the opens
event will fire each time you land on that screen.
This is my previous finding months ago but should you want to test this behaviour again, I’m willing to participate.
[Edit]
I forgot to mention that the screen behaves differently when using the phone’s swipe gesture or back key from using the navigate to screen block
. This makes it even more difficult to control. That is when screens are not part of a navigator.
1 Like
Hmm… that’s interesting. I wondered about navigators with respect to this. I really want a way to do this.
Here’s a workaround I think could work:
Or true/false. Doesn’t have to be a count.
2 Likes
If you want some code to execute only once then YES this is a workaround.