Swiftpack.co - hhru/HandlersKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by hhru.
hhru/HandlersKit 1.2.0
HandlersKit is a light-weight iOS Framework that allows you to use modern closure syntax instead of the target-action and delegate patterns
⭐️ 35
🕓 1 year ago
iOS tvOS
.package(url: "https://github.com/hhru/HandlersKit.git", from: "1.2.0")

HandlersKit

Build Status Codecov Cocoapods Carthage compatible SPM compatible Xcode Swift License

HandlersKit is a light-weight iOS Framework that allows you to use modern closure syntax instead of the target-action and delegate patterns. This framework covers the most popular UIKit classes.

Overview

Closure syntax instead of UIControl's target-action mechanism.

control.on(.valueChanged) {
    print("UIControl's value changed")
}

Convenient methods for the most common cases.

button.onTap {
    print("UIButton touch up inside")
}
slider.onChange { newValue in
   print("UISlider changed value")
}

Access to the same object inside the closure without typecasting or optional unwrapping.

let button = MyActivityIndicatorButton()
button.onTap { (sender: MyActivityIndicatorButton) in
    sender.showActivityIndicator()
}

Every method allows chaining.

textField.shouldChangeString { fromString, toString in
    print("\(fromString) -> \(toString)")
    return true
}.shouldBeginEditing {
    true
}.didEndEditing {
    print("UITextField did end editing")
}

Benefits

Requirements

  • iOS 12.0+ / tvOS 12.0+
  • Xcode 13.0+
  • Swift 5.5+

Installation

CocoaPods

To install HandlersKit using CocoaPods add the following line to your Podfile:

pod 'HandlersKit'

Then run in Terminal:

$ pod install

Carthage

To integrate HandlersKit into your project using Carthage, specify it in your Cartfile:

github "hhru/HandlersKit"

Swift Package Manager

To integrate HandlersKit into your project using Swift Package Manager, you have two different ways:

  1. In Xcode, go to File > Swift Packages > Add Package Dependency... and enter the following URL:
https://github.com/hhru/HandlersKit
  1. Or add the following as a dependency to your Package.swift:
.package(url: "https://github.com/hhru/HandlersKit.git", from: "1.2.0")

Manual

  • Go to releases page.
  • Download the latest release Source code.
  • Drag and drop all .swift files from HandlersKit-x.y.z/Sources folder into your Xcode project. Check the option Copy items if needed.

License

HandlersKit is released under the MIT License. (see LICENSE).

GitHub

link
Stars: 35
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1.2.0
1 year ago

What's Changed

Full Changelog: https://github.com/hhru/HandlersKit/compare/1.1.1...1.2.0

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics