Minimum iOS 8.0
To run the example project, clone the repo, and open LambdaUI.xcworkspace
LambdaUI is available through CocoaPods. To install it, add the following line to your Podfile:
pod "LambdaUI"
LambdaUI is an closure driven event handling framework for Swift. It reduces the effort needed when assigning events to UI elements in Swift. It also features easy and intuitive GCD support.
Once you've added the LambdaUI
framework to your project, a new events
property will be available on all instances of UIControl
objects (for example, UIButton
, UIStepper
, UISlider
, etc.). This property contains all of the supported events for a given UIControl
let button = UIButton()
button.events.touchUpInside += { _ in
print("Touched the button")
}
let stepper = UIStepper()
let eventIdentidier = stepper.events.valueChanged += { _ in
print("Stepper changed value")
}
if shouldDisableStepperEvents {
stepper.events.valueChanged -= eventIdentidier
}
let slider = UISlider()
slider.events.valueChanged += async {
print("async event")
}
slider.events.valueChanged += async(queue: .UserInteractiveQueue) { _ in
print("async event on user interactive queue")
}
@IBOutlet weak var button : UIButton!
override func viewDidLoad() {
super.viewDidLoad()
let firstEventIdentifier = button.events.touchUpInside += { _ in
print("Do first event")
}
button.events.touchUpInside += async(queue: .BackgroundQueue) { _ in
//Disable first event once the second event has been triggered
button.events.touchUpInside -= firstEventIdentifier
}
}
Any contributions are welcome. Just respect the usual contribution etiquette. Submit a pull request and it will be reviewed as soon as possible.
Mislav Javor, mislav.javor@outlook.com
LambdaUI is available under the MIT license. See the LICENSE file for more info.