Skip to content

Instantly share code, notes, and snippets.

@timothyjoel
timothyjoel / CombineWebservice.swift
Last active May 30, 2020 14:47 — forked from stinger/CombineFetcherAndDecoder.swift
Combine - fetching and decoding JSON data
import Foundation
import Combine
class Webservice {
private let dataFetcher = DataFetcher()
func fetch<T: Decodable>(url: URL) -> AnyPublisher<T, WebserviceError> {
dataFetcher.fetchData(url: url)
.receive(on: RunLoop.main)