I've seen a dozen or so tutorials on how to use Combine and receive a Notification of a task being completed. It seems they all show linear code - the publisher and receiver all in the same place, one row after another.
Publishing a notification is as easy as the code below:
// background download task complete - notify the appropriate views
DispatchQueue.main.async {
NotificationCenter.default.post(name: .dataDownloadComplete, object: self, userInfo: self.dataCounts)
}
extension Notification.Name {
static let dataDownloadComplete = Notification.Name("dataDownloadComplete")
}
SwiftUI has the onReceive() modifier, but I can't find any way to connect the above to a "listener" of the posted notification.
How does a View receive this Notification