CombineCocoa icon indicating copy to clipboard operation
CombineCocoa copied to clipboard

FeatureRequest: Add handlers for selectors

Open maximkrouk opened this issue 3 years ago • 4 comments

Feature request

In ReactiveCocoa there is an ability to subscribe to object selector's trigger like

navigationController?.reactive
        .trigger(for: #selector(UINavigationController.popViewController))
        .producer.observe(on: UIScheduler()).startWithValues { ... }

I think this feature is very useful and it would be great if Combine had this ability too 🙏

maximkrouk avatar Jun 21 '21 21:06 maximkrouk

Btw I implemented it here (took ReactiveCocoa/ReactiveSwift as a reference), but I changed indentation and added macOS support (not features adoption, but an ability to build), removed carthage & cocoapods support and updated readme a bit, so I don't think the PR is useful, and if you interested, you can adopt this feature manually or tell me to create a PR anyway 🙂

Example:

navigationController?.publisher(for: #selector(UINavigationController.popViewController))

maximkrouk avatar Jun 25 '21 21:06 maximkrouk

@maximkrouk This is BRILLIANT!!! Just what I need to finally completely remove RxSwift from my project. Do you mind to make a PR? It's a bit old, do you need any help updating it for usage?

viewDidAppear avatar Jul 27 '23 13:07 viewDidAppear

Hello @viewDidAppear, I just extracted this logic to combine-interception package, it should be compatible with CombineExt/CombineCocoa

maximkrouk avatar Jul 27 '23 15:07 maximkrouk

Oh @maximkrouk Thanks! I didn't see this so I prepared a PR of my own, with a fork against current master. Let me see if I can use your package instead 🤩

viewDidAppear avatar Jul 27 '23 15:07 viewDidAppear