Swiftpack.co - msaadq/networking-with-combine as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by msaadq.
msaadq/networking-with-combine v0.9
SPM library for making simple network calls using Combine framework
⭐️ 3
🕓 4 years ago
.package(url: "https://github.com/msaadq/networking-with-combine.git", from: "v0.9")

Networking With Combine

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
            })

GitHub

link
Stars: 3
Last commit: 4 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

4 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics