# Any tips for making my function more reliable

**URL:** <https://community.thunkable.com/t/any-tips-for-making-my-function-more-reliable/1243737>\
**Category:** Questions about Thunkable X\
**Created:** [April 24, 2021, 8:29pm UTC](https://community.thunkable.com/t/any-tips-for-making-my-function-more-reliable/1243737 "2021-04-24T20:29:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas.sjdtomypv](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@andreas.sjdtomypv](https://community.thunkable.com/u/andreas.sjdtomypv)\
**Post date:** [April 24, 2021, 8:29pm UTC](https://community.thunkable.com/t/any-tips-for-making-my-function-more-reliable/1243737/1 "2021-04-24T20:29:18Z")

</div>

Hi  
I have a function in my app that works as expected 95% of the times, but 5% the function acts weird. Can anyone give me some advice what I could do to make it more reliable and hit 100%?

The function is a swipe left, and it will pass the user to a new screen where you can edit an item in a list, which will then pass you back to the “main” screen again.  
The list is a local data list viewer but it also store the list in Airtable. So the update first goes for the local list, then the same update runs for the Airtable as well.

This is how the code is setup:

Variable:  
 ![Screenshot 2021-04-24 at 21.54.42](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/d/bdd33b7e44552fdb36240f8b9d35e9741869c0ec.png)

The swipe function:

 ![Screenshot 2021-04-24 at 21.55.04](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/1/51e4e05791b2bdd718af24bdcf38a355d50e8b4c.png)

The “update”-function on the “editScreen”:

 ![Screenshot 2021-04-24 at 21.54.32](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/5/15582fccf289cc1ccf12b9744d4d3e3130207d5e.png)

Mostly it works great (I can live with the delay for the update, I guess that’s caused by Airtable and Thunkable comunication?)

I’ll add some links with video-clips showing how it mostly works and should be working and also the issues that sometimes appears.

1. This is how it mostly appears and which is fine for me:  
[Dropbox - myApp-Ok behaviour.mov - Simplify your life](https://www.dropbox.com/s/2xyb6mz980ep92w/myApp-Ok%20behaviour.mov?dl=0)

2. Sometimes when I delete some rows before editing any row, some or all of the deleted files shows up again. (this is happening very rarely ) I guess it has something to do with the Airtable is not updated?  
[Dropbox - myApp-Issue 1.mov - Simplify your life](https://www.dropbox.com/s/y8jxyb09zommkeh/myApp-Issue%201.mov?dl=0)

3. Sometimes it just doesn’t happen anything so I need to re-do it and it works.  
[Dropbox - myApp-Issue 2.mov - Simplify your life](https://www.dropbox.com/s/tzuw2amx5kzp3j5/myApp-Issue%202.mov?dl=0)

This Is my startup block for screen1 which is the screen that the function is taking me to after updated the item. In that block I will get all the data from Airtable, filter it two view only the current users items, and then add those items to the dataListViewer which is the one that I see in the app.

 ![Screenshot 2021-04-24 at 22.20.35](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/d/3db17a2bc484e92567390926c5981d90eff39459.png)

Please advise me if you got any ideas when seeing this. I have been thinking about adding a pause before getting the airtable-rows in start-block for screen1, just to give it a chance to update in Airtable first, but then again I do not want to slow down the appearance in the app…  
How would you have done?

Thanks!

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [April 24, 2021, 11:30pm UTC](https://community.thunkable.com/t/any-tips-for-making-my-function-more-reliable/1243737/2 "2021-04-24T23:30:44Z")

</div>

You need to read more about how to better use asynchronous function. Most of database functions work in asynchronous mode which means the block next to it will run and not wait the database action to finish and therefore you are experiencing such situations.

---

<div class="post-metadata">

**Author:** ![andreas.sjdtomypv](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@andreas.sjdtomypv](https://community.thunkable.com/u/andreas.sjdtomypv)\
**Post date:** [April 25, 2021, 7:15am UTC](https://community.thunkable.com/t/any-tips-for-making-my-function-more-reliable/1243737/3 "2021-04-25T07:15:22Z")

</div>

Thanks. That feels exactly like what I am missing.  
Do you have any tips where I can learn about that?

I will google around and see if I find anything.

Thanks.

---

<div class="post-metadata">

**Author:** ![andreas.sjdtomypv](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@andreas.sjdtomypv](https://community.thunkable.com/u/andreas.sjdtomypv)\
**Post date:** [April 25, 2021, 7:31am UTC](https://community.thunkable.com/t/any-tips-for-making-my-function-more-reliable/1243737/4 "2021-04-25T07:31:22Z")

</div>

Is this what you mean?

> [@Wrapping Asynchronous (then do) blocks into a Synchronous Function resolves unpredictable results](https://community.thunkable.com/t/wrapping-asynchronous-then-do-blocks-into-a-synchronous-function-resolves-unpredictable-results/910511):
>
> Thunkable provides an extensive library of calls to external services including Google Docs and Web APIs. These external calls are, by necessity, asynchronous calls. That is, the request is sent to the external serivce, Thunkable block execution continues on it’s merry way, then the external service sends a reply. Thunkable wraps the external calls in in blocks with “Then Do” sections. This is a massive improvement over separate call and response block (MIT App Inventor), but it is not without …

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [April 25, 2021, 9:39am UTC](https://community.thunkable.com/t/any-tips-for-making-my-function-more-reliable/1243737/5 "2021-04-25T09:39:50Z")

</div>

Yes, although the post was talking about Firebase RTDB but the asynchronous info is general to all Data Sources.

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:22pm UTC](https://community.thunkable.com/t/any-tips-for-making-my-function-more-reliable/1243737/6 "2024-11-08T13:22:57Z")

</div>


