NetworkClient Protocol Reference
public protocol NetworkClient
Protocol for sending network requests and handling responses.
-
Sends a
URLRequestas is and completes with aNetworkResult. It returns aDisposablethat can be disposed to cancel the request sent.Request lifecycle events are sent to the request interceptors and they are retried, when necessary, following the
RequestInterceptorlogic.Declaration
Swift
func sendRequest(_ request: URLRequest, completion: @escaping (NetworkResult) -> Void) -> DisposableParameter Description requestthe
URLRequestthat is sent in theURLSession.dataTaskcompletionthe block that is called once the request is completed either with a success or with an unretryable error
Return Value
the
Disposablethat can be used to dispose the request and cancel the dataTask and future retries. -
Creates a new
NetworkClientfrom this instance which will use a specific logger.Declaration
Swift
func newClient(withLogger logger: LoggerProtocol) -> SelfParameter Description loggerThe logger that will be used for this instance
Return Value
A new
NetworkClientinstance.