Understanding how widgets work
As mentioned at the beginning of this chapter, widgets are not mini applications. Instead, widgets are simple views that show relevant information and are updated according to a declared timeline or app events.
Widgets run on a different process than the app. They receive a runtime to perform any code, so they work as static views, showing pre-made information to our users. But, since our user’s data is being constantly updated, we can create an array of entries, each with information and a date. The WidgetCenter is responsible for creating a different view for each one of the entries, storing it, and replacing the widget UI according to the entries’ dates. This array of entries is called a timeline.
One good example is the Next Event widget. The Next Event widget shows the next event in our calendar, and since we have access to our user’s calendar, we can build a timeline and refresh the widget data based on the calendar event...