Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- import FutureKit
- extension Future {
- public final func onSuccessTry<__Type>(executor: Executor, block:(result:T) throws -> __Type) -> Future<__Type> {
- return onSuccess(executor) { result -> Completion<__Type> in
- do {
- let blockResult = try block(result: result)
- return .Success(blockResult)
- }
- catch let error {
- return .Fail(error)
- }
- }
- }
- public final func onSuccessTry<__Type>(block:(result:T) throws -> __Type) -> Future<__Type> {
- return onSuccess { result -> Completion<__Type> in
- do {
- let blockResult = try block(result: result)
- return .Success(blockResult)
- }
- catch let error {
- return .Fail(error)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement