Javascript Wait Action

1 Like

What is the purpose of this app?

1 Like

This app makes use of the JavaScript experimental code plugin and JavaScript setTimeout function to delay changes to columns in a table. The setTimeout or Sleep functions can be used to simulate animation or display a slideshow to users. There are likely hundreds of other possible uses.

To implement a JavaScript setTimeout (wait) function, use the experimental JS plugin https://column.sh/hell-yes-code as the source of an experimental code column, and in your Glide table column input the following as the code:

if (p1 == 1) {await new Promise(r => setTimeout(r, 3000)); return 1;}

Any time your Glide app user changes the value of p1 the system waits 3 seconds and then sets the value of that column to 1.

You can then easily make a chain of experimental codes from there, each previous experimental code changing the next code’s value after 3 seconds.

2 Likes

Unfortunately, I can’t share the app yet as the Glide Team won’t allow sharing of apps using the experimental code. I will post images later on, if someone needs more detailed instruction on how it works.

1 Like

Glide natively refreshes at 10 seconds - so this is nice to give developers more options to control the user experience.

1 Like

You can use a glide native duration column to apply delays , no need for code

1 Like

What is that? I am not seeing that in the documentation or forum.

1 Like

I’m very curious. Could you please elaborate?

1 Like

Timestamp the current time, and use math column to substract it from the time now… you will get the duration, now you can do IF column to check for any duration you desire

4 Likes

Cool tip, I have already read about setTime() function but I never thought to use it in Glide, thanks to share it @noobly_channel

I don’t think it can be replicated natively in Glide. As Mark wrote above, Glide natively refreshes each 10 secs and this applies to its Now() function too.

Saludos!

4 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.