func testData()->AnyPublisher<DemoObject, APIError> { var data = DummyData().decodeClaimDetails()! return (Just(data).eraseToAnyPublisher(), APIError.httpError(200)) }
I got this error. Cannot convert return expression of type '(AnyPublisher<DemoObject, Never>, APIError)' to return type 'AnyPublisher<DemoObject, APIError>'
How can I return a type that is AnyPublisher<DemoObject, APIError>?
You want
func testData()->AnyPublisher<DemoObject, APIError> { let d: DemoObject = // ... return Just<DemoObject>(d) .setFailureType(to: APIError,self) // <-- .eraseToAnyPublisher() }
1.4m articles
1.4m replys
5 comments
57.0k users