I tried creating an instance of Action<AnyObject?, Bool, NSError> of ReactiveCocoa 3.
let action: Action<AnyObject?, Bool, NSError> = Action { _ in
if self.flag {
return self.fooSignalProducer // SignalProducer<Bool, NoError>
} else {
return self.barSignalProducer // SignalProducer<Bool, NSError>
}
}
This code isn't able to compile with error 'SignalProducer<Bool, NoError>' is not convertible to 'SignalProducer<Bool, NSError>'.
How can I convert SignalProducer<Bool, NoError> to SignalProducer<Bool, NSError>?
You can use the
mapErroroperator. Something along the lines of:Edit:
As Justin points out below,
promoteErrorsis specifically designed for this case: