ConnectivityManager
public class ConnectivityManager : ConnectivityManagerProtocol, RequestInterceptor
A manager that handles system connectivity monitor and empirical connectivity monitor to establish when connectivity is actually available or not on the device.
See connectionAssumedAvailable for how the two are combined.
-
The shared instance of the
ConnectivityManagerDeclaration
Swift
public static let shared: ConnectivityManager -
Shortcut for
connectionAssumedAvailable.value. It isfalsewhenever the system monitor reports no connection, whatever the empirical connectivity says.Declaration
Swift
public var isConnectionAssumedAvailable: Bool { get } -
The current network connection state from the connectivity monitor.
Declaration
Swift
public var connection: ObservableState<NetworkConnection> { get } -
An observable that emits
truewhen connection is assumed to be available andfalsewhen it’s assumed to be unavailable.The internal behavior is to merge the information from the system connectivity monitor and the result of network requests: connected reports as available, not connected reports as unavailable, and unknown follows the empirical connectivity result.
Declaration
Swift
@StateSubject public var connectionAssumedAvailable: ObservableState<Bool> { get } -
Feeds
EmpiricalConnectivityfrom the result of every request attempt.Here we always assume that the response is never coming from a local cache.
Declaration
Swift
public func onAttemptResult(_ request: URLRequest, retryCount: Int, with result: NetworkResult) -
Never retries: the
ConnectivityManageronly observes the completed requests.Declaration
Swift
public func shouldRetry(_ request: URLRequest, consecutiveRetryCount: Int, with response: NetworkResult) -> RetryPolicy
View on GitHub