// // LearnMapKitApp.swift // LearnMapKit // // Created by Jacky Jack on 05/06/2024. // import SwiftUI import Collections //https://www.hackingwithswift.com/quick-start/swiftui/how-to-run-code-when-your-app-launches @main struct LearnMapKitApp: App { @State var queue: Deque = [] @StateObject private var flightState = FlightState() init() { print("Init app") var update_postions: Deque = [] DispatchQueue.global(qos: .background).sync { print("Dispatch") //var count = 0 //let ADSBtask = ADSBRunner() //queue.append(MapADSBData(lat: 0.0, long: 0.0, alt: 1)) /* let timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in print("Timer fired! \(count)") ADSBtask.runFromFile() update_postions.append(MapADSBData(lat: 0.0, long: 0.0, alt: 1)) print(update_postions.count) count += 1 }*/ print("Exit dispatch") } //push all new data to state queue from a runner DispatchQueue.global(qos: .background).sync { // Update the UI on the main thread let c = queue.count } } var body: some Scene { WindowGroup { ContentView(pos_queue: $queue) }.environmentObject(flightState) } }