Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chorim/combineinterception
Allowing you to subscribe to the invocation of Objective-C methods.
https://github.com/chorim/combineinterception
combine ios objective-c rxswift swift
Last synced: 2 months ago
JSON representation
Allowing you to subscribe to the invocation of Objective-C methods.
- Host: GitHub
- URL: https://github.com/chorim/combineinterception
- Owner: chorim
- License: mit
- Created: 2023-01-08T15:32:39.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-26T15:11:54.000Z (over 1 year ago)
- Last Synced: 2024-11-29T14:56:47.311Z (2 months ago)
- Topics: combine, ios, objective-c, rxswift, swift
- Language: Swift
- Homepage: https://github.com/EduDo-Inc/CombineCocoa
- Size: 19.5 KB
- Stars: 11
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CombineInterception
## WARNING
### If that [PR](https://github.com/CombineCommunity/CombineCocoa/pull/88) is merged, it will add functionality to CombineCocoa.
### Please use CombineCocoa in future.##
CombineInterception is a library that provides functionality similar to the methodInvoked function from RxCocoa, allowing you to subscribe to the invocation of Objective-C methods.
Reference from https://github.com/EduDo-Inc/CombineCocoa
## Usage
TL;DR```swift
import UIKit
import Combine
import CombineInterceptionextension UIViewController {
var viewDidLoadPublisher: AnyPublisher {
let selector = #selector(UIViewController.viewDidLoad)
return publisher(for: selector)
.map { _ in () }
.eraseToAnyPublisher()
}
var viewWillAppearPublisher: AnyPublisher {
let selector = #selector(UIViewController.viewWillAppear(_:))
return intercept(selector)
.map { $0[0] as? Bool ?? false }
.eraseToAnyPublisher()
}
}class ViewController: UIViewController {
private var subscriptions = Set()
private func bind() {
viewDidLoadPublisher
.sink(receiveValue: { _ in
print("viewDidLoad")
})
.store(in: &subscriptions)
viewWillAppearPublisher
.sink(receiveValue: { isAnimated in
print("viewWillAppearPublisher", isAnimated)
})
.store(in: &subscriptions)
}
}
```## Dependencies
This project has the following dependencies:
* Combine.framework
## Installation
### Swift Package Manager
Add the following dependency to your Package.swift file:
```swift
.package(url: "https://github.com/chorim/CombineInterception.git", from: "0.1.0")
```## Acknowledgments
* CombineInterception was created by referencing https://github.com/EduDo-Inc/CombineCocoa
## License
MIT, See the [LICENSE](LICENSE) file.
The Combine framework are property of Apple Inc.