I am working with ReactiveSwift 3.x in an iOS project and have been unable to map over an error provided by one SignalProducer
into a different one.
My NoError SignalProducer
is:
func foo() -> SignalProducer<Void, NoError>
The function being called within foo()
that I want to map is:
func bar() -> SignalProducer<Data, MyError>
I currently have the following:
func foo() -> SignalProducer<Void, NoError> {
// Stuff happens here...
return bar()
.map({ _ -> Void in
return ()
})
.mapError({ error -> NoError in
print(error.localizedDescription)
// I do not want to handle this error
return NoError
})
}
But I am getting the error:
'mapError' produces 'SignalProducer< Void, F >', not the expected contextual result type 'SignalProducer< Void, NoError >'
Ultimately, I just want to print out the error, and then return.
Quack.
I had attempted some flatMapError work earlier, but got it to work with the following:
.flatMapError({ error -> SignalProducer<Void, NoError> in
return SignalProducer.empty
})