You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by apocolipse <gi...@git.apache.org> on 2016/11/12 21:46:10 UTC
[GitHub] thrift issue #1084: THRIFT-3773 Swift 3 Native Library
Github user apocolipse commented on the issue:
https://github.com/apache/thrift/pull/1084
Update:
I've modified the generated Async clients to use a new `TAsyncResult<T>` parameter for callbacks rather than Optional Return/Error tuples. Short version of why is that those parameters are always mutually exclusive, and there's no really good way to have a non-optional return or throw pattern for async.
With the `TAsyncResult<T>`, non-optional return values are encapsulated within a throwing func in the enum, such that you can handle your do/catch block in a callback. Consider the following example:
```swift
/// normal: public func hello() throws -> String
do {
let world = try hello()
} catch let e { handle(e) }
/// async: public func hello(completion: @escaping (TAsyncResult<String>) -> Void)
hello() {
do {
let world = try $0.value()
catch let e { handle(e) }
}
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---