SwiftUI know when new page from TabView is activated

In my view I've done this:

Code Block swift
var body: some View {
  TabView {
    DayView(summary: History.shared.today())
    DayView(summary: History.shared.thisWeek())
    DayView(summary: History.shared.thisMonth())
  }
  .tabViewStyle(PageTabViewStyle())
}


how do I tell the appropriate DayView when it has become the active page? If it matters for implementation, this is specifically when using WatchOS.

You can pass in a variable
Code Block Swift
@State private var selectedTab = 0
to the TabView and to the DayViews
Code Block Swift
TabView(selection: $selectedTab) {
DayView(summary: History.shared.today(), tab: $selectedTab).tag(0)
DayView(summary: History.shared.thisWeek(), tab: $selectedTab).tag(1)
DayView(summary: History.shared.thisMonth(), tab: $selectedTab).tag(2)
}

SwiftUI know when new page from TabView is activated
 
 
Q