Skip to content

cx-org/CXCocoa

Repository files navigation

CombineX.Cocoa(中文)

release install platform license dicord

Notice

This library is still in beta, so do not use it in production!

🐱

What is CXCocoa

Like ReactiveCocoa and ReaciveSwift, RxCocoa and RxSwift, CXCocoa is a derivative of CombineX. It provides Combine extensions to Cocoa Framework, making it easier to write Cocoa-related asynchronous code.

It includes but is not limited to:

  • MethodPublisher/DeallocatePublisher, intercepting method calls with method swizzle
  • KVOPublisher, observing property changes through the KVO mechanism
  • DelegateProxy, forwarding delegate message
  • UIKit extensions(binder & property), subscribing control event and binding values
  • UIScheduler
  • ...

You can freely switch the underlying dependency between CombineX and Combine.

Demo

Install

CocoaPods

pod 'CXCocoa', :git => 'https://github.com/cx-org/CXCocoa.git', :branch => 'master'

Carthage

github "cx-org/CXCocoa" "master"

What is Combine/CombineX

Check here.

Contribution

Welcome! Any kind of contribution is welcome at any time!!!

You can:

  1. Add more control extensions, especially for macOS controls.
  2. Add documentation.
  3. Make your suggestions.
  4. Star! Then tell your friends!

Because the upstream CombineX is still in beta, if you encounter a strange problem in this library - then it may drift from upstream. 🤣

Use with Combine

You can change the underlying dependency to Combine by passing USE_COMBINE to the target's build configurations. For example, if you are using CocoaPods, you can modify your podfile like below:

post_install do |installer|
    installer.pods_project.targets.each do |target|
        if target.name == 'CXExtensions'
            target.build_configurations.each do |config|
                config.build_settings['OTHER_SWIFT_FLAGS'] = '-DUSE_COMBINE'
            end
        end
    end
end

If you are using Carthage, you should be able to use XCODE_XCCONFIG_FILE to do that.

Acknowledgement

The implementation of the library references both ReactiveCocoa and RxCocoa, especially ReactiveCocoa, the ObjC part is almost completely modified from its source code, really appreciate to their great work!