Skip to content

Commit

Permalink
Update Task.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
fmo91 committed Feb 8, 2017
1 parent de8f85c commit dcf0e94
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions FOTask/Classes/Task.swift
Expand Up @@ -109,3 +109,20 @@ public extension Task {
}
}
}

public extension Task {
public func map<C>(_ f: @escaping (B) -> C) -> Task<A, C> {
return BasicTask<A, C> { (input: A) in
return { (onSuccess: @escaping (C) -> Void, onError: @escaping (Error) -> Void) in
self.perform(input,
onSuccess: { (output: B) in
onSuccess(f(output))
},
onError: { (error: Error) in
onError(error)
}
)
}
}
}
}

0 comments on commit dcf0e94

Please sign in to comment.