A Swift framework that adds closure handlers to UIKit and Foundation classes, replacing delegation and target-action patterns.
Closures is an iOS framework that adds closure-based handlers to UIKit and Foundation classes, allowing developers to replace delegation and target-action patterns with more concise and functional Swift code. It simplifies UI interaction handling, data population for views, and event management through a clean, chainable API.
iOS developers working with UIKit who prefer functional programming styles or want to reduce boilerplate code associated with delegation and target-action patterns.
Developers choose Closures for its Swifty, type-safe approach that avoids Objective-C runtime tricks, its flexibility to mix with traditional patterns, and its concise API that improves code readability and organization.
Swifty closures for UIKit and Foundation
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Replaces verbose target-action and delegation with simple closures, as shown with `button.onTap { }` and `mySwitch.onChange { }`, drastically reducing boilerplate code for common UI interactions.
Allows mixing closure handlers with traditional delegate methods without lock-in, enabling gradual adoption—demonstrated in the 'Retain Control' section where UITableView can use custom delegates alongside closures.
Simplifies data source implementation for table and collection views by populating directly from arrays with methods like `tableView.addElements()`, minimizing repetitive cell configuration code.
Built using Swift's strong-typed system without Objective-C runtime tricks, ensuring better compile-time safety and seamless integration with modern Swift features, as emphasized in the philosophy section.
The framework openly hopes to be 'sherlocked' by Apple's API improvements, posing a risk of deprecation and future migration efforts if native closure support is added to UIKit.
Exclusively targets UIKit and Foundation classes with no support for SwiftUI, making it irrelevant for apps adopting Apple's modern UI framework and limiting its long-term relevance.
Closure-based handlers can inadvertently cause retain cycles if developers don't use weak references, requiring more careful memory management compared to delegation's inherent weak references.