aschuch/Argonaut

Ambiguous use of 'mapToType'

aloco opened this issue ยท 1 comments

aloco commented

Just stumbled over that when using Argonaut with Moya+ReactiveCocoa where your often use .toSignalProducer()

reproducible in ReactiveJSONMappingTests.swift with
userJSONSignal.toSignalProducer() |> mapToType(User.self)

Xcode 6.3.2 ๐Ÿƒ

toSignalProducer() returns SignalProducer<AnyObject?, NSError> as opposed to SignalProducer<AnyObject, NSError> that is expected by mapToType.

I have successfully tested this using

var user: User?

userJSONSignal.toSignalProducer() |> tryMap { (x: AnyObject?) -> Result<AnyObject, NSError> in
    if let x: AnyObject = x {
        return Result.success(x)
    }
    return Result.failure(NSError())
}
|> mapToType(User.self)
|> start(next: { user = $0 })