Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Sources/MBAsyncNetworking/Config/NetworkableConfigs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,11 @@ public enum NetworkableConfigs {
public func set(configuration: URLSessionConfiguration) {
Session.shared.configuration = configuration
}

/// Configures the URLSession to wait for network connectivity before attempting requests.
/// When enabled, requests will wait for an appropriate network connection to become available.
/// - Parameter shouldWait: `true` to wait for connectivity, `false` to fail immediately if no network is available.
public func setConnectivityWaiting(_ shouldWait: Bool) {
Session.shared.setConnectivityWaiting(shouldWait)
}
}
12 changes: 12 additions & 0 deletions Sources/MBAsyncNetworking/Config/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ public final class Session {
)
}

/// Sets the connectivity waiting behavior for the URLSession configuration.
/// This recreates the URLSession with the updated configuration.
/// - Parameter shouldWait: Whether the session should wait for connectivity before making requests.
func setConnectivityWaiting(_ shouldWait: Bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URL stub ile çakışmasın? önce bu set edilir sonra stub set edilirse ne olur? tüm session set edilme durumları için gereçli sorum.

configuration.waitsForConnectivity = shouldWait
session = URLSession(
configuration: configuration,
delegate: delegate,
delegateQueue: nil
)
}

/// Structure to define timeout configurations for URLSession
struct TimeOut {
/// The timeout interval when waiting for additional data
Expand Down