Simple network bicycle:)
Example
DataTaskProcessor()
.startTask(url: TestRoute.url, method: .get)
.decode(on: [String: String].self)
.perform(in: .main)
.map(\.count)
.onComplete { countOfKeys in
print(countOfKeys)
}
.onError { error in
print(error)
}
or with Publisher
@available(iOS 13, *)
DataTaskProcessor()
.startTask(url: TestRoute.url, method: .get)
.publisher
.compactMap(\.data)
.decode(type: [String: String].self, decoder: JSONDecoder())
.sink { result in
switch result {
case .finished:
print("Success!")
case .failure(let error):
print("Error \(error.localizedDescription)")
}
} receiveValue: { response in
print(response)
}
.store(in: &cancellabelEventsContainer)