Classes
The following classes are available globally.
-
BasicNetworkServicehandles network request for resources by using a givenNetworkAccess.Example:
// Just use an URLSession for the networkAccess. let basicNetworkService: NetworkService = BasicNetworkService(networkAccess: URLSession(configuration: .default))See moreSeealso
NetworkServiceDeclaration
Swift
public final class BasicNetworkService : NetworkService
-
A task which contains another task which can be updated in fligh. Use this task to compose a chain of requests during the original request. An oAuth Flow would be a good example for this.
See moreNote
Take look atRetryNetworkServiceto see how to use it in detail.Declaration
Swift
public final class ContainerNetworkTask : NetworkTask
-
ModifyRequestNetworkServicecan be composed with a network service to modify all outgoing requests. One could add auth tokens or API keys for specifics URLs.Example:
let networkService: NetworkService = // let modifyRequestNetworkService = ModifyRequestNetworkService(networkService: networkService, requestModifications: [ { request in return request.added(HTTPHeaderFields: ["API-Key": "SecretKey"]) }])Note
Requests can only be modified syncronously.See moreSeealso
NetworkServiceDeclaration
Swift
public final class ModifyRequestNetworkService : NetworkService
-
Mocks a
NetworkService. You can configure expected results or errors to have a fully functional mock.Example:
See more//Given let networkServiceMock = NetworkServiceMock() let resource: Resource<String> = // //When networkService.request( resource, onCompletion: { string in /*...Declaration
Swift
public final class NetworkServiceMock : NetworkService
-
Mock implementation for
See moreNetworkTask.Declaration
Swift
public class NetworkTaskMock : NetworkTask
-
RetryNetworkServicecan request resource. When a request fails with a given condtion it can retry the request after a given time interval. The count of retry attemps can be configured as well.See moreSeealso
NetworkServiceDeclaration
Swift
public final class RetryNetworkService : NetworkService
View on GitHub
Classes Reference