Created
November 26, 2023 02:32
-
-
Save simonbromberg/83a540f28bcd9b2de12202b91e0d4823 to your computer and use it in GitHub Desktop.
BlockConfigurable
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
import UIKit | |
public protocol BlockConfigurable {} | |
extension NSObject: BlockConfigurable {} | |
extension BlockConfigurable {} | |
public extension UIView { | |
@discardableResult | |
convenience init(block: (UIView) -> Void) { | |
self.init() | |
block(self) | |
} | |
} | |
public extension BlockConfigurable { | |
@discardableResult | |
func then(_ block: (Self) -> Void) -> Self { | |
block(self) | |
return self | |
} | |
@discardableResult | |
func then(_ block: (Self) throws -> Void) throws -> Self { | |
try block(self) | |
return self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment