session .dataTaskPublisher(for: url) .validateStatusCode { (200..<300).contains($0) } .validateResponse { !$0.data.isEmpty } .mapErrorJson(to: ApiErrorResponse.self, decoder: decoder) .mapValueJson(to: ApiValueResponse.self, decoder: decoder) .sink( receiveCompletion: { print("Completion/Failure: \($0)") }, receiveValue: { print("Value: \($0)") } ) Declarative Networking