PadCodedocs

Refresh Widget

Draws the widget again with fresh data: its When Shown steps run again, like a Call API. On a widget's button, a tap refreshes that widget; in an app, the app's widgets on the Home Screen.

Category: Device

#When to use it

Use it for a refresh button on a widget that shows data from the web: a price, the weather, a score. Its When Shown steps, like a Call API, run again, and the widget shows what they get.

#Example

A Refresh button on a widget, with a Refresh Widget step. Its widget's When Shown trigger has a Call API step that fills price, and a Text shows {price}. Tap the button on the Home Screen and the price is fetched again.

#Good to know

  • On a widget's button, it refreshes that widget, without opening PadCode. Steps before it run first, so a button can change a value and then refresh.
  • In an app, it refreshes the app's widgets on the Home Screen, with what the app remembers now. Use it after a step that changes something its widgets show.
  • iPadOS decides how often widgets refresh on their own. A Refresh Widget step, or Reload Widgets in the Shortcuts app, asks for one straight away. See Widgets.

#Add it

Select a view, open the Inspector's Actions tab, pick when it runs, tap Add action and choose Refresh Widget (under Device). Tap the step to open its settings.

#Settings

None.

#See also