Thomvis / BrightFutures

Write great asynchronous code in Swift using futures and promises

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Will FutureProofing be getting an update soon?

kenlaws opened this issue · comments

@Thomvis if you have no time for FutureProofing add me as collaborator
I can update it to swift 3 (after merging my PR Thomvis/FutureProofing#6 of course)

Thanks for the offer @phimage. I've added you as a contributor to FutureProofing. Looking forward to Swift 3 support!

FutureProofing updated to swift 3 Thomvis/FutureProofing@94d4236

I create a file BrightFuture+FutureProofing.swift to be able to use generic Error into completion handler (It's inspired from PR #108)
Then I add @escaping to materialize function

Later some code could be reported to BrightFuture and more

public extension DispatchQueue {

    public func asyncResult<T>(_ execute: @escaping () throws -> T) -> Future<T, AnyError> {
        return Future { completion in
            async {
                do {
                   try completion(.success(execute()))
                } catch let e {
                    completion(.failure(AnyError(cause: e)))
                }
            }
        }
    }

}