I want to create extension on SignalProducerType as below.
extension SignalProducerType{
func mapR() -> SignalProducer<[String:AnyObject], XError> {
return attemptMap { (value: [String:AnyObject]) -> Result<[String:AnyObject], XError> in
return Result(value: ["1":1])
}
}
}
XError is defined as ErrorType
public enum XError: ErrorType{
case Invalid
case Unsuccessful
}
But this won't compile and error is.
'attemptMap' produces 'SignalProducer', not the expected contextual result type 'Result<[String : AnyObject], XError>' (aka 'Result, XError>')
You are extending SignalProducerType who has generic associated types
ValueandError, which means self is a generic type e.g.SignalProducer<Value, Error>. So you can't call attempMap with concrete value type [String:AnyObject] and concrete error type XError.Replace the first line
extension SignalProducerTypewith