mxcl / PromiseKit

Promises for Swift & ObjC.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Map always returns a Promise not a value/object

terracotta-ko opened this issue · comments

PromiseKit: 6.13.1 by CocoaPods, Swift 5, XCode: 12.3

I tried to return a value from a promise chain and I have checked the Troubleshooting guide.

However, the compiler keeps telling that map will return a promise no matter what.

Could anyone help me with this issue?

Screen Shot 2021-01-14 at 21 32 27

Map is a transformer function so you can map from Promise<A> to Promise<B> but it's still going to be a Promise of some type afterwards.

In the example you show, I'd return Promise<EmailLoginResultDomain> from the function and then at the calling site add the .done closure to handle what you want to do with the EmailLoginResultDomain and a .catch to handle the errors from the Promise chain.

Not sure on the logic you are looking to produce but the unused default Failure seems like a candidate for a .recover on the chain