I am working on integrating widget support into an existing app and have a question regarding the best practices for reloading a widget. For context, the existing app allows the user to add a playlist widget which will show the title, track count, and thumbnail associated with that playlist.
Within the app, playlists can of course be edited which will change the data that should be reflected on the widget. In addition, edits may happen over and over, in quick succession (ex. deleting multiple tracks, reordering tracks, etc).
My question is as follows: should the widget be reloaded every time an edit is made, or is there a way to mark a widget as needing to be reloaded?
Considering the use case where a user is editing a playlist and makes 10-20 changes in quick succession, it feels wasteful to reload a widget 10-20 times for each small change. However, the app doesn't necessarily know when the user is going to stop editing or terminate the app, so it's important that the widget is reloaded rather proactively.
In addition to the above question, is there any way to only reload a specific, single widget, rather than all widgets or all widgets of a certain kind?
Considering the use case where a user may have 3-4 playlist widgets on their homescreen, it also feels wasteful to reload all of them when only one of the playlists may have been edited. Yet, from my understanding of WidgetCenter
, the only two functions for reloading a widget are reloadAllTimelines
and reloadTimelines(ofKind:)
which seem to only allow broad reloading.