- Notifications
You must be signed in to change notification settings - Fork12
🍩 Unified communication patterns with easy closure in Swift
License
onmyway133/EasyClosure
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
❤️ Support my apps ❤️
- Push Hero - pure Swift native macOS application to test push notifications
- PastePal - Pasteboard, note and shortcut manager
- Quick Check - smart todo manager
- Alias - App and file shortcut manager
- My other apps
❤️❤️😇😍🤘❤️❤️
There are manyCommunication patterns
Sometimes, you just want a unified and quick way to do it. Just callon
on anyNSObject
subclasses and handle your events the quickest way
- Shortcut to handle actions and events
- Easy to extend
- Correct method suggestion based on generic protocol constraint
- Support iOS, macOS
We can make a fun demo ofgood, cheap, fast
withUISwitch
func allOn()->Bool{return[good, cheap, fast].filter({ $0.isOn}).count==3}good.on.valueChange{ _inifallOn(){ fast.setOn(false, animated:true)}}cheap.on.valueChange{ _inifallOn(){ good.setOn(false, animated:true)}}fast.on.valueChange{ _inifallOn(){ cheap.setOn(false, animated:true)}}
button.on.tap{print("button has been tapped")}
slider.on.valueChange{ valueinprint("slider has changed value")}
textField.on.textChange{ textinprint("textField text has changed")}
textView.on.textChange{ textinprint("textView text has changed")}
searchBar.on.textChange{ textinprint("searchBar text has changed")}
datePicker.on.pick{ dateinprint("datePicker has changed date")}
barButtonItem.on.tap{print("barButtonItem has been tapped")}
gestureRecognizer.on.occur{print("gesture just occured")}
ExtendContainer
and specifyHost
to add more functionalities to your own types. For example
publicextensionContainerwhere Host:UITableView{func cellTap(_ action:@escaping(UITableViewCell)->Void)){ // Your code here here}}// usagelettableView=UITableView()tableView.on.cellTap{ cellin}
EasyClosure is available throughCocoaPods. To installit, simply add the following line to your Podfile:
pod'EasyClosure'
EasyClosure is also available throughCarthage.To install just write into your Cartfile:
github"onmyway133/EasyClosure"
EasyClosure can also be installed manually. Just download and dropSources
folders in your project.
Khoa Pham,onmyway133@gmail.com
We would love you to contribute toEasyClosure, check theCONTRIBUTING file for more info.
EasyClosure is available under the MIT license. See theLICENSE file for more info.
About
🍩 Unified communication patterns with easy closure in Swift