Skip to content

Commit c0dd945

Browse files
committed
Add @discardableResult to UIView animates
I resisted, because why use these if you don’t intend to use the Guarantee? But it turns that I use these because their API is better than Apple’s where there are no default parameters.
1 parent 4659059 commit c0dd945

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Sources/UIView+Promise.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,28 @@ public extension UIView {
4040
- Returns: A promise that fulfills with a boolean NSNumber indicating
4141
whether or not the animations actually finished.
4242
*/
43+
@discardableResult
4344
static func animate(_: PMKNamespacer, duration: TimeInterval, delay: TimeInterval = 0, options: UIViewAnimationOptions = [], animations: @escaping () -> Void) -> Guarantee<Bool> {
4445
return Guarantee { animate(withDuration: duration, delay: delay, options: options, animations: animations, completion: $0) }
4546
}
4647

48+
@discardableResult
4749
static func animate(_: PMKNamespacer, duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping damping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions = [], animations: @escaping () -> Void) -> Guarantee<Bool> {
4850
return Guarantee { animate(withDuration: duration, delay: delay, usingSpringWithDamping: damping, initialSpringVelocity: initialSpringVelocity, options: options, animations: animations, completion: $0) }
4951
}
5052

53+
@discardableResult
5154
static func transition(_: PMKNamespacer, with view: UIView, duration: TimeInterval, options: UIViewAnimationOptions = [], animations: (() -> Void)?) -> Guarantee<Bool> {
5255
return Guarantee { transition(with: view, duration: duration, options: options, animations: animations, completion: $0) }
5356
}
5457

58+
@discardableResult
5559
static func transition(_: PMKNamespacer, from: UIView, to: UIView, duration: TimeInterval, options: UIViewAnimationOptions = []) -> Guarantee<Bool> {
5660
return Guarantee { transition(from: from, to: to, duration: duration, options: options, completion: $0) }
57-
}
58-
59-
static func perform(_: PMKNamespacer, animation: UISystemAnimation, on views: [UIView], options: UIViewAnimationOptions = [], animations: (() -> Void)?) -> Guarantee<Bool> {
60-
return Guarantee { perform(animation, on: views, options: options, animations: animations, completion: $0) }
61+
}
62+
63+
@discardableResult
64+
static func perform(_: PMKNamespacer, animation: UISystemAnimation, on views: [UIView], options: UIViewAnimationOptions = [], animations: (() -> Void)?) -> Guarantee<Bool> {
65+
return Guarantee { perform(animation, on: views, options: options, animations: animations, completion: $0) }
6166
}
6267
}

0 commit comments

Comments
 (0)