Swiftpack.co - Package - cx-org/CXCompatible


travis release install platform license dicord

CXCompatible provides compatibility shims for CombineX. Using it, you can write code that is compatible with both Combine and CombineX, in other words, you can freely switch dependencies between Combine and CombineX without modifying the code base.

import CXFoundation
import CXCompatible

let task = Timer.cx.publish(every: 1, on: RunLoop.main, in: .default)
    .sink { date in
        // task

Why do I need CXCompatible

You should already know CombineX, which is an open source implementation of Combine. One of its purposes is to provide an API that is completely consistent with Combine, but unfortunately this is somewhat impossible.

Combine directly extends some system types and provides them with a pub-sub interface, such as:

let nums = [0, 1, 2].publisher

let task = URLSession.share.dataTaskPublisher(for: endpoint)

CombineX tries to provide the same functionality, but it can't use the same API, such as:

extension Sequence {
    // Error: ambiguous use of ...
    public var publisher: Publishers.Sequence {
        // ...

extension URLSession {
    // Swift doesn't allow you to redefine types of the same name, even in a different framework.
    public struct DataTaskPublisher: Publisher {
        // ...

CombineX's solution is cx:

let nums = [1, 2, 3].cx.publisher

let task = URLSession.share.cx.dataTaskPublisher(for: endpoint)

Yes, this breaks the consistency of CombineX and Combine. To make this code compatible with Combine, CXCompatible implements an alternative implementation of all cx interfaces, but based on Combine.


Swift Package Manager

    .package(url: "https://github.com/cx-org/CXCompatible", .branch("master"))


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


github "cx-org/CXCompatible" "master"



Stars: 3
Help us keep the lights on


Used By

Total: 0


0.0.1-beta.4 - Sep 11, 2019

0.0.1-beta.3 - Sep 11, 2019

0.0.1-beta.2 - Sep 8, 2019

0.0.1-beta.1 - Sep 7, 2019