Skip to content

Commit

Permalink
Make blocks throwable
Browse files Browse the repository at this point in the history
  • Loading branch information
ddddxxx committed Nov 10, 2017
1 parent 1891b2f commit 61e1b73
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Sources/Then/Then.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ extension Then where Self: Any {
/// $0.origin.x = 10
/// $0.size.width = 100
/// }
public func with(_ block: (inout Self) -> Void) -> Self {
public func with(_ block: (inout Self) throws -> Void) rethrows -> Self {
var copy = self
block(&copy)
try block(&copy)
return copy
}

Expand All @@ -49,8 +49,8 @@ extension Then where Self: Any {
/// $0.set("devxoul@gmail.com", forKey: "email")
/// $0.synchronize()
/// }
public func `do`(_ block: (Self) -> Void) {
block(self)
public func `do`(_ block: (Self) throws -> Void) rethrows {
try block(self)
}

}
Expand All @@ -64,8 +64,8 @@ extension Then where Self: AnyObject {
/// $0.textColor = UIColor.blackColor()
/// $0.text = "Hello, World!"
/// }
public func then(_ block: (Self) -> Void) -> Self {
block(self)
public func then(_ block: (Self) throws -> Void) rethrows -> Self {
try block(self)
return self
}

Expand Down

0 comments on commit 61e1b73

Please sign in to comment.