Moya: func didReceive(_ result: Result<Moya.Response, MoyaError>, target: TargetType) {} No call

Created on 18 Apr 2019  ·  10Comments  ·  Source: Moya/Moya

Pod 'Moya', '13.0.0'

Xcode10.2.1 Swift5.0

The custom plugin, called the method in the protocol extension, did not call the method in the custom class, is it caused by ‘Result’ in Swift5.0?

Most helpful comment

@CDYeah I see,You might not have imported Result

please import Result

All 10 comments

Same here :( I has faced it since Swift Moya 12.0.1

Hey @CDYeah @ntnthien. Would you be able to provide an example code that reproduces the issue so I could investigate it further?

I have the same problem. Has anyone solved it yet。
我遇到了同样的问题, 有人解决问题了没

Alamofire (4.8.2)、RxSwift 4.5.0、 Moya (13.0.0)、Result (4.1.0)

pod 'Moya/RxSwift'

@CDYeah You can try the NetworkActivityPlugin

@CDYeah I see,You might not have imported Result

please import Result

The custom plugin must import Result... I spent a lot of time at this

@_exported import Kingfisher

Kingfisher is imported globally, conflicting with import Result

I'm sorry you guys are experiencing this problem. #1839 might resolve it in the future.

Why do we need to import Result?

@WeMadeCode I was confused by this too! If you don't explicitly import Result, it defaults to using Swift's Result type. Your method still compiles because the methods on the two Result types are so similar. It _looks_ (to a human) like we are implementing the protocol but we aren't because the types don't match - the protocol wants Result.Result, you are using Swift.Result.

The compiler doesn't complain because all the protocol methods are optional :) Though this would be a nice warning for the compiler to output in cases like this . . .

Was this page helpful?
0 / 5 - 0 ratings