A collection of useful extensions for Combine and CombineX.
Ignore error from upstream and complete.
// Output: (data: Data, response: URLResponse), Failure: URLError
let upstream = URLSession.shared.cx.dataTaskPublisher(for: url)
// Output: (data: Data, response: URLResponse), Failure: Never
let pub = upstream.ignoreError()
Auto cancel after delay.
let delayedCancel = upstream
.sink { o in
}
.cancel(after .second(1), scheduler: mainScheduler)
dependencies.append(
.package(url: "https://github.com/cx-org/CXExtensions", .branch("master"))
)
pod 'CXExtensions', :git => 'https://github.com/cx-org/CXExtensions.git', :branch => 'master'
github "cx-org/CXExtensions" "master"
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.