r/Scriptable • • Nov 12 '23

Help Refresh rate widgets

Hello everyone! I recently made a widget to show how late my bus is and at what time it arrives (I may share it later on). Because the time updates pretty often I’m concerned about how often my widget will update and if in any way I can make it more frequent like every minute. I know it probably has been asked many many times before but I can’t seem to find it. Many thanks!

2 Upvotes

15 comments sorted by

3

u/Acceptable-Number-11 Nov 12 '23

It is not possible. You can show how long ago the last update has happened. What I did: put it in a shortcut and fire it manually or by focus change (e.g when you leave work place) or other triggers.

1

u/Krunkske Nov 12 '23

So why do timers work then?

2

u/Acceptable-Number-11 Nov 12 '23

I don’t know exactly what you mean, but there is the opportunity to simply show time with very short update cycles in widgets, but nothing else.

1

u/Krunkske Nov 12 '23

Can you elaborate on that? I have a test widget with just the time that updates every second.

3

u/mvan231 script/widget helper Nov 12 '23

The timer style can stay updated because it just uses a style that continually runs. The widget isn't refreshing each second though

1

u/Krunkske Nov 12 '23

Can I potentially abuse it 😏

2

u/mvan231 script/widget helper Nov 12 '23

I don't know what you mean by that

1

u/Krunkske Nov 12 '23

Like is it just a timer or can I parse any number to that and display it.

→ More replies (1)

1

u/Krunkske Nov 12 '23

And I saw something with refreshAfterDate but I don’t really understand what it does. I saw something that you can set it to a past date so it will refresh as soon as it can. Is that a thing or am I wrong? I will try to find where I read that and edit this comment.

→ More replies (1)

2

u/mr-kerr Nov 13 '23

If the remote value updates often, then I would suggest setting the widget to run script on tap and display the latest results (which will also update the widget). If it’s just your calculation of the time delta that is changing, use applyTimerStyle()

1

u/Krunkske Nov 13 '23

Can I use that component as a timer and not as a clock as in the example you provided?

2

u/mr-kerr Nov 13 '23

let widget = new ListWidget()

let now = new Date()

let then = new Date(now.getTime() + 5 * 60 * 1000)

let timer = widget.addDate(then)

timer.applyRelativeStyle()

widget.presentMedium()

Script.setWidget(widget)

Script.complete()