CombineNetwork

Platform Cocoapods PM

CombineNetwork provides simple interfaces for making a network call using Combine.framework.

Installation

Cocoapods

Include the following line in the Podfile

pod CombineNetwork

Swift package manager

Add a Package Dependency using the current Github URL

Reference

Sample

Test JSON file

https://swapi.co/api

JSON model

struct StarWars: Decodable {
    let films: String
}

Retrieve data from the JSON file

let client = APIClient()
let url = URL(string: "https://swapi.dev/api/")!
let subscriber = Subscribers.Sink<StarWars?, APIError>(
    receiveCompletion: { print($0) },
    receiveValue: { print($0) })
client.requestObject(from: url, using: .get)
    .subscribe(subscriber)