Skip to content

Instantly share code, notes, and snippets.

@simonbromberg
Created November 26, 2023 02:32
Show Gist options
  • Save simonbromberg/83a540f28bcd9b2de12202b91e0d4823 to your computer and use it in GitHub Desktop.
Save simonbromberg/83a540f28bcd9b2de12202b91e0d4823 to your computer and use it in GitHub Desktop.
BlockConfigurable
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