Add sample project CI build workflows (#8)
Remove unnecessary flag from workflow
Update RxSwift 5 project package.resolve file to use version 1 for CI support
Update RxSwift 5 project minimum deployment target to 13.0
Update RxSwift 6 project minimum deployment target to 13.0
Update RxSwift 6 project package.resolve file
Add RxSwift 5 sample app build workflow
Add RxSwift 6 sample app build workflow
Co-authored-by: Jack.Stone Jack.Stone@global.com
CombineRx
The CombineRx library contains a series of functions that help with the interoperability between RxSwift and Apple’s Combine frameworks.
Interoperability between Combine and RxSwift
Combine to RxSwift
In order to convert Combine
Publisher
s to RxSwiftObservable
s, you can make use of theasObservable()
function. This can be done as follows:RxSwift to Combine
In order to convert RxSwift
Observable
s to CombinePublisher
s, you can make use of theasPublisher(withBufferSize:andBridgeBufferingStrategy:)
function. This can be done as follows:One difference between RxSwift and Combine is that Combine adheres to the mechanism of backpressure in order to ensure that
Publisher
s only produce as many elements thatSubscriber
s have requested. This prevents the case where elements might build up in aPublisher
s buffer faster than they can be processed downstream by a subscriber as this could lead to out-of-memory errors and degradation in performance due to high system resource consumption. Combine applies this backpressure upstream through a contractual obligation byPublisher
s to only emit an element when it is requested bySubscriber
s throughSubscribers.Demand
requests.RxSwift
Observable
s differ in this regard as they rely on a source with an unbounded rate of production and therefore when bridging to a CombinePublisher
, we must maintain a buffer or drop elements accordingly in order to satisfy the requirements of downstream subscribers.This is the reason for the required
withBufferSize
andandBridgeBufferingStrategy
parameters forasPublisher(withBufferSize:andBridgeBufferingStrategy:)
.withBufferSize
is where the buffer size should manually be set (ideally based directly on the number of expected elements in the sequence).andBridgeBufferingStrategy
is the strategy to employ when the maximum buffer capacity is reached. Keeping in line with native Combine strategies, this can either beerror
, where any buffer overflow is treated as an error,dropNewest
where the elements already present in the buffer are maintained and any new elements are ignored, or finallydropOldest
where new elements are added to the buffer and replace older elements that were already present.Additional information on Combine’s use of backpressure can be found here.
Installation
It is currently possible to install this library using Swift Package Manager. In order to do so, please add the current repository as a package dependency using Xcode or include the following in your
Package.swift
file:Copywrite and license information
Copyright 2020 © Jack Stone
CombineRx is made available under the MIT License