Closed Faktorealchik closed 1 year ago
I tried test project with async await, and I think it's not working
Could you please give me a hint how it might be used with async/await ? Do you plan to add support for it?
changed test code:
// The MIT License (MIT) // // Copyright (c) 2020–2023 Alexander Grebenyuk (github.com/kean). import SwiftUI import Pulse import PulseUI @main struct Pulse_Demo_iOSApp: App { var body: some Scene { let _ = testProxy() WindowGroup { NavigationView { ConsoleView() } } } } private func testProxy() { URLSessionProxyDelegate.enableAutomaticRegistration() let session = URLSession(configuration: .default, delegate: MockSessionDelegate(), delegateQueue: nil) let request = URLRequest(url: URL(string: "https://catfact.ninja/fact")!) Task { do { let response = try await session.data(for: request) print(response) } catch { print(error) } } } private final class MockSessionDelegate: NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLSessionDownloadDelegate { var completion: ((URLSessionTask, Error?) -> Void)? func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { completion?(task, error) } func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) { print("here") } }
screenshot of the app after the code is completed:
Also I've tried my own app, the new request are showing in console view, but they are stale in 'pending' status
https://github.com/kean/Pulse/issues/113 duplicate
I tried test project with async await, and I think it's not working
Could you please give me a hint how it might be used with async/await ? Do you plan to add support for it?
changed test code:
screenshot of the app after the code is completed:
Also I've tried my own app, the new request are showing in console view, but they are stale in 'pending' status