Created
May 9, 2017 14:21
-
-
Save AndreyPanov/5d673ef80a88a21348f77d04013ba556 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Chainable: class { | |
var before: (()->())? { get set } | |
func before(_ callback: @escaping ()->()) -> Self | |
func invoke() | |
} | |
extension Chainable { | |
@discardableResult | |
func before(_ callback: @escaping ()->()) -> Self { | |
before = callback | |
return self | |
} | |
func invoke() { | |
before?() | |
before = nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment