import SwiftUI

@Observable class ApplicationData {
   var total: Int = 0
   @ObservationIgnored var titles: [String] = []

   static let shared: ApplicationData = ApplicationData()
   private init() {
      Task {
         await readNotifications()
      }
   }
   func readNotifications() async {
      let center = NotificationCenter.default
      let name = Notification.Name("Update Data")

      for await _ in center.notifications(named: name, object: nil) {
         await MainActor.run {
            total = titles.count
         }
      }
   }
}