Replies: 6 comments
-
I think it’s notable that Swift NIO’s Future type doesn’t do this. Not to say I’m against it, but it seems like this change could cascade into quite an end-user burden, perhaps your experience with Alamofire here is proof? So I'm all for it, provided it never becomes a PITA for our end-users. I've always cared that this library is the most pleasant futures library for Swift/ObjC, so, you know. |
Beta Was this translation helpful? Give feedback.
-
The last major update to NIO was released just after the release of Swift 5, so it's likely there wasn't time to make such a significant change, if it was even considered. In a quick search I can't find any issues discussing making the type doubly generic at all, so it's also likely it hasn't been suggested since it became possible in the language with We'll see how the change in Alamofire works out, as it's a very recent change between the betas and RCs. In most usage, the doubly generic type and the standardization of |
Beta Was this translation helpful? Give feedback.
-
Yeah, given this thought. Seems like the right choice. |
Beta Was this translation helpful? Give feedback.
-
One example is the function from RequestInterceptor that comes from Alamofire. Example of function that uses Result
|
Beta Was this translation helpful? Give feedback.
-
NIO still doesn’t. How did it work out with Alamofire? |
Beta Was this translation helpful? Give feedback.
-
NIO hasn't made a major release since May, 2019, so I don't think that means much. Alamofire shipped v5 in Feb. 2020 (took a while) and I haven't heard any complaints about the generic error. Just a few cases of v4 -> v5 migration needing to handle That said, given Swift hasn't added typed throws yet, and the proliferation of throwing with the new async APIs, it seems likely dealing with In the end, however, I'm no longer working on the codebase that is using PromiseKit and so no longer have this need. It still seems like a good idea. You can also help a bit by offering |
Beta Was this translation helpful? Give feedback.
-
As development of v7 is well underway, and I just ran into this limitation, I thought I'd make the request:
Promise
should be generic to itsError
type.This was previously, and extensively, discussed in #135. However, it's been over 4 years and much has changed, including the addition of
Result
to the language and the fact thatError
now conforms to itself, making possible a fully type-safe error pipeline. We recently made this change in Alamofire, making ourResponse
types generic to theFailure
type as well as theSuccess
type. However, for projects using Alamofire (or any API that produces typed errors) and PromiseKit, this creates a rather tedious developer experience of having to cast back out to the known error type before processing. Personally, I don't see much in the way of a downside.What do you think?
Beta Was this translation helpful? Give feedback.
All reactions