RefreshView API User Experience
Reliable content refresh is a fundamental web UX requirement and can be either user-driven or app-invoked.
A typical flow for a user-triggered refresh is:
- A Lightning web component displays a button (or other user interface control) to start a process that synchronizes the data being displayed in the component with its source.
- When the button is tapped, the button component dispatches a
- The nearest level container component, which is registered with the RefreshView API, receives the
RefreshEvent, stopping its propagation.
- The components’ refresh handlers initiate the refresh process on the appropriate components. They can display spinners, perform instrumentation, and do other things to prepare the UI to be refreshed.
- Descendant components of the handler participate in the refresh process through exposed API hooks. They can fetch data from a Salesforce org or perform other tasks to synchronize displayed data with the external data source.
- The refresh for the component hierarchy completes when all data is synchronized and updated onscreen.
For an app-triggered refresh:
- An application determines that a refresh is needed for a view to ensure the data is synchronized. For example, a refresh is needed after a reauthentication from an expired session, or after a pull-to-refresh action on a mobile UI.
- From this point, the refresh flow is similar to that described above for user-triggered refreshes.