Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/capturecontext/combine-interception
Package extending Apple' `Combine` framework for interception of objc selectors.
https://github.com/capturecontext/combine-interception
combine extensions frp interception macros objc-runtime reactive reactive-programming runtime selectors spm swift swift-macro swift-macros swift-package-manager swift-runtime
Last synced: about 21 hours ago
JSON representation
Package extending Apple' `Combine` framework for interception of objc selectors.
- Host: GitHub
- URL: https://github.com/capturecontext/combine-interception
- Owner: CaptureContext
- License: mit
- Created: 2023-07-27T15:01:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-28T03:39:54.000Z (9 months ago)
- Last Synced: 2024-11-14T00:47:53.658Z (7 days ago)
- Topics: combine, extensions, frp, interception, macros, objc-runtime, reactive, reactive-programming, runtime, selectors, spm, swift, swift-macro, swift-macros, swift-package-manager, swift-runtime
- Language: Swift
- Homepage:
- Size: 45.9 KB
- Stars: 5
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# combine-interception
[![CI](https://github.com/CaptureContext/combine-interception/actions/workflows/ci.yml/badge.svg)](https://github.com/CaptureContext/combine-interception/actions/workflows/ci.yml) [![SwiftPM 5.9](https://img.shields.io/badge/swiftpm-5.9-ED523F.svg?style=flat)](https://swift.org/download/) ![Platforms](https://img.shields.io/badge/Platforms-iOS_13_|_macOS_10.15_|_Catalyst_13_|_tvOS_14_|_watchOS_7-ED523F.svg?style=flat) [![@capturecontext](https://img.shields.io/badge/[email protected]?style=flat&logo=twitter)](https://twitter.com/capture_context)
Combine API for interception of objc selectors in Swift.
## Usage
### Basic
Observe selectors on NSObject instances
```swift
navigationController.intercept(_makeMethodSelector(
selector: UINavigationController.popViewController,
signature: navigationController.popViewController
))
.sink { result in
print(result.args) // `animated` flag
print(result.output) // popped `UIViewController?`
}
```You can also simplify creating method selector with `CombineInterceptionMacros` if you are open for macros
```swift
navigationController.intercept(
#methodSelector(UINavigationController.popViewController)
).sink { result in
print(result.args) // `animated` flag
print(result.output) // popped `UIViewController?`
}
```> Macros require `swift-syntax` compilation, so it will affect cold compilation time
### Library
If you use it to create a library it may be a good idea to export this one implicitly
```swift
// Exports.swift
@_exported import CombineInterception
```It's a good idea to add a separate macros target to your library as well
```swift
// Exports.swift
@_exported import CombineInterceptionMacros
```## Installation
### Basic
You can add CombineInterception to an Xcode project by adding it as a package dependency.
1. From the **File** menu, select **Swift Packages › Add Package Dependency…**
2. Enter [`"https://github.com/capturecontext/combine-interception.git"`](https://github.com/capturecontext/combine-interception.git) into the package repository URL text field
3. Choose products you need to link them to your project.### Recommended
If you use SwiftPM for your project, you can add CombineInterception to your package file.
```swift
.package(
url: "https://github.com/capturecontext/combine-interception.git",
.upToNextMinor(from: "0.3.0")
)
```Do not forget about target dependencies:
```swift
.product(
name: "CombineInterception",
package: "combine-interception"
)
``````swift
.product(
name: "CombineInterceptionMacros",
package: "combine-interception"
)
```## License
This library is released under the MIT license. See [LICENCE](LICENCE) for details.
See [ACKNOWLEDGMENTS](ACKNOWLEDGMENTS) for inspiration references and their licences.