Classes

The following classes are available globally.

  • BasicNetworkService handles network request for resources by using a given NetworkAccess.

    Example:

    // Just use an URLSession for the networkAccess.
    let basicNetworkService: NetworkService = BasicNetworkService(networkAccess: URLSession(configuration: .default))
    

    Seealso

    NetworkService
    See more

    Declaration

    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.

    Note

    Take look at RetryNetworkService to see how to use it in detail.
    See more

    Declaration

    Swift

    public final class ContainerNetworkTask : NetworkTask
  • ModifyRequestNetworkService can 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.

    Seealso

    NetworkService
    See more

    Declaration

    Swift

    public final class ModifyRequestNetworkService : NetworkService
  • Mocks a NetworkService. You can configure expected results or errors to have a fully functional mock.

    Example:

    //Given
    let networkServiceMock = NetworkServiceMock()
    let resource: Resource<String> = //
    
    //When
    networkService.request(
       resource,
       onCompletion: { string in /*...
    
    See more

    Declaration

    Swift

    public final class NetworkServiceMock : NetworkService
  • RetryNetworkService can 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.

    Seealso

    NetworkService
    See more

    Declaration

    Swift

    public final class RetryNetworkService : NetworkService