Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.

Commit

Permalink
Add optional delegate to network
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLeif committed Apr 3, 2024
1 parent e125f52 commit a6dafc2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Sources/Network/Network.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import Foundation

/// A class that implements the `Networking` protocol to perform network requests using URLSession.
open class Network: Networking {
public init() { }
public weak var delegate: URLSessionTaskDelegate?

public init(delegate: URLSessionTaskDelegate? = nil) {
self.delegate = delegate
}

open func request(
for url: URL,
Expand All @@ -17,7 +21,10 @@ open class Network: Networking {
request.httpBody = body

return DataResponse(
try await URLSession.shared.data(for: request)
try await URLSession.shared.data(
for: request,
delegate: delegate
)
)
}

Expand Down

0 comments on commit a6dafc2

Please sign in to comment.