This is an SPM library (How to add Swift Package to XCode Project?) for making simple network calls using Combine framework.
Available for:
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
})
link |
Stars: 3 |
Last commit: 4 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics