This is an SPM library (How to add Swift Package to XCode Project?) for making simple network calls using Combine framework.
Available for:
- iOS 13.0+
- macOS 10.15+
- tvOS 13.0+
- watchOS 6.0+
All the network calls return a Combine publisher of type AnyPublisher with APIError.
Example usage with Codable Object:
let cancellable = NetworkingWithCombine.getAPIResponseMapper(modelObject: SampleCodableClass.self, queryURL: someURL, params: nil)
.sink(receiveCompletion: { (completion) in
switch completion {
case .failure(let error):
print(error.localizedDescription)
case .finished:
// Add debug statements or triggers
}
}, receiveValue: { value in
// Utilize the returned SampleCodableClass object
})
Example usage with Images:
let cancellable = NetworkingWithCombine.getImageFetcher(imageUrl: someURL)
.sink(receiveCompletion: { (completion) in
switch completion {
case .failure(let error):
print(error.localizedDescription)
case .finished:
// Add debug statements or triggers
}
}, receiveValue: { value in
// Utilize the returned Image
})