Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/CombineCommunity/CombineCocoa
Combine publisher bridges for UIKit
https://github.com/CombineCommunity/CombineCocoa
hacktoberfest
Last synced: about 1 month ago
JSON representation
Combine publisher bridges for UIKit
- Host: GitHub
- URL: https://github.com/CombineCommunity/CombineCocoa
- Owner: CombineCommunity
- License: mit
- Created: 2019-08-03T10:20:16.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-08-21T04:00:44.000Z (4 months ago)
- Last Synced: 2024-10-29T15:34:41.473Z (about 1 month ago)
- Topics: hacktoberfest
- Language: Swift
- Homepage:
- Size: 1.41 MB
- Stars: 1,662
- Watchers: 29
- Forks: 131
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-combine - Combine Cocoa
README
# CombineCocoa
CombineCocoa attempts to provide publishers for common UIKit controls so you can consume user interaction as Combine emissions and compose them into meaningful, logical publisher chains.
**Note**: This is still a primal version of this, with much more to be desired. I gladly accept PRs, ideas, opinions, or improvements. Thank you ! :)
## Basic Examples
Check out the [Example in the **Example** folder](https://github.com/freak4pc/CombineCocoa/blob/main/Example/Example/ControlsViewController.swift#L27). Open the project in Xcode 11 and Swift Package Manager should automatically resolve the required dependencies.
## Usage
tl;dr:
```swift
import Combine
import CombineCocoatextField.textPublisher // AnyPublisher
segmented.selectedSegmentIndexPublisher // AnyPublisher
slider.valuePublisher // AnyPublisher
button.tapPublisher // AnyPublisher
barButtonItem.tapPublisher // AnyPublisher
switch.isOnPublisher // AnyPublisher
stepper.valuePublisher // AnyPublisher
datePicker.datePublisher // AnyPublisher
refreshControl.isRefreshingPublisher // AnyPublisher
pageControl.currentPagePublisher // AnyPublisher
tapGesture.tapPublisher // AnyPublisher
pinchGesture.pinchPublisher // AnyPublisher
rotationGesture.rotationPublisher // AnyPublisher
swipeGesture.swipePublisher // AnyPublisher
panGesture.panPublisher // AnyPublisher
screenEdgePanGesture.screenEdgePanPublisher // AnyPublisher
longPressGesture.longPressPublisher // AnyPublisher
scrollView.contentOffsetPublisher // AnyPublisher
scrollView.reachedBottomPublisher(offset:) // AnyPublisher
```## Installation
### CocoaPods
Add the following line to your **Podfile**:
```rb
pod 'CombineCocoa'
```### Swift Package Manager
Add the following dependency to your **Package.swift** file:
```swift
.package(url: "https://github.com/CombineCommunity/CombineCocoa.git", from: "0.2.1")
```### Carthage
Add the following to your **Cartfile**:
```
github "CombineCommunity/CombineCocoa"
```## Future ideas
* Support non `UIControl.Event`-based publishers (e.g. delegates).
* ... your ideas? :)## Acknowledgments
* CombineCocoa is highly inspired by RxSwift's [RxCocoa](https://github.com/ReactiveX/RxSwift) in its essence, kudos to [Krunoslav Zaher](https://twitter.com/KrunoslavZaher) for all of his amazing work on this.
* Thanks to [Antoine van der Lee](https://twitter.com/twannl) for his tutorial on [Creating Custom Publishers](https://www.avanderlee.com/swift/custom-combine-publisher/). The idea to set up a control target inside the publisher was inspired by it.## License
MIT, of course ;-) See the [LICENSE](LICENSE) file.
The Apple logo and the Combine framework are property of Apple Inc.