Reload Policy tells the system when to call timeline() again
once it has run through all the entries you gave it.
.never → never call timeline() again automatically
.atEnd → call timeline() again after last entry passes
.after(date) → call timeline() again at a specific date
.neverreturn Timeline(entries: [entry], policy: .never)
System will NOT call timeline() again on its own.
Widget stays frozen on the last entry until something
explicitly tells it to refresh.
When to use:
User has pinned a specific state via Intent Configuration
→ no point reloading, nothing will change unless user edits widget
How to manually trigger a reload from the main app:
WidgetCenter.shared.reloadAllTimelines()
Call this from your main app whenever data changes
→ forces the system to call timeline() again
.atEndreturn Timeline(entries: entries, policy: .atEnd)
System calls timeline() again after the last entry's date passes.
Used when you have a fixed schedule that needs to repeat.
From the project's original version:
// 5 entries, one per hour
return Timeline(entries: entries, policy: .atEnd)
Entry 0 → 1:00 PM
Entry 1 → 2:00 PM
Entry 2 → 3:00 PM
Entry 3 → 4:00 PM
Entry 4 → 5:00 PM ← last entry
↓
policy kicks in → system calls timeline() again
→ builds 5 fresh entries starting from 5:00 PM
.after(date)let refreshDate = Calendar.current.date(byAdding: .hour, value: 1, to: Date())!
return Timeline(entries: entries, policy: .after(refreshDate))
System calls timeline() again at exactly the date you specify.
Used when you know precisely when new data will be available.