• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Updating Widget Content
2
3The ArkTS widget framework provides the [updateForm](../reference/apis-form-kit/js-apis-app-form-formProvider.md#updateform) API for widget providers and the **requestForm** API for widget hosts to proactively trigger widget page refreshes. It also alerts providers to update widgets based on the scheduled information.
4
5In widget UI code, you can use [LocalStorageProp](../quick-start/arkts-localstorage.md#localstorageprop) to obtain the widget data that requires updating, sent by the provider
6
7| API| System Capability| Constraints|
8| -------- | -------- | -------- |
9| updateForm | No| 1. Invoked by the widget provider.<br>2. Allows only the widget provider to update its own widgets.|
10| requestForm | Yes| 1. Invoked by the widget host.<br>2. Allows only the widget host to update the widgets added to it.|
11
12
13
14Widget provider proactively updating a widget
15
16![updateForm](figures/updateForm.PNG)
17
18If there is a need to update widget data, the widget provider, as long as it is running, can proactively update the widget using the **updateForm** API provided by formProvider.
19
20
21
22Widget host proactively requesting a widget update
23
24![requestForm](figures/requestForm.PNG)
25
26If changes in system language or color scheme are detected, the widget host, as long as it is running, can proactively request to update the widget using the **requestForm** API provided by formHost. The widget manager then instructs the widget provider to complete the update.
27
28
29
30Widget manager instructing the widget provider to periodically update a widget
31
32![timer_updateForm](figures/timer_updateForm.PNG)
33
34Based on the scheduled update information configured by the widget provider, the widget manager determines whether to instruct the provider to update the widget, considering factors such as timing information, widget visibility status, and the number of updates.
35
36
37
38The following are the typical use cases of widget updates:
39
40- [Interval-based Widget Updates](arkts-ui-widget-update-by-time.md)
41- [Time-specific Widget Updates](arkts-ui-widget-update-by-time-point.md)
42- [Updating Local and Online Images in the Widget](arkts-ui-widget-image-update.md)
43- [Updating Widget Content by State](arkts-ui-widget-update-by-status.md)
44