Skip to content

Commit

Permalink
Return cadisplaylink on operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Conte Mac Donell committed Jun 8, 2017
1 parent d16c3c2 commit 6b22055
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion LambdaKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'LambdaKit'
s.version = '0.0.4'
s.version = '0.1.0'
s.license = 'MIT'
s.summary = 'Closures on most used UIKit methods'
s.homepage = 'https://github.com/Reflejo/LambdaKit'
Expand Down
7 changes: 5 additions & 2 deletions Source/CADisplayLink+LambdaKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,20 @@ extension CADisplayLink {
///
/// - parameter duration: The duration in seconds.
/// - parameter handler: The closure to execute for every tick.
public class func runFor(_ duration: CFTimeInterval, handler: @escaping LKDisplayLinkClosure) {
public static func runFor(_ duration: CFTimeInterval,
handler: @escaping LKDisplayLinkClosure) -> CADisplayLink
{
let displayLink = CADisplayLink(target: self, selector: #selector(CADisplayLink.tick(_:)))

displayLink.closureWrapper = ClosuresWrapper(handler: handler, duration: duration)
displayLink.add(to: RunLoop.main, forMode: RunLoopMode.defaultRunLoopMode)
return displayLink
}

// MARK: Private methods

@objc
private class func tick(_ displayLink: CADisplayLink) {
private static func tick(_ displayLink: CADisplayLink) {
guard let closureWrapper = displayLink.closureWrapper else {
return
}
Expand Down

0 comments on commit 6b22055

Please sign in to comment.