CombineCommunity/rxswift-to-combine-cheatsheet

RxSwift to Apple’s Combine Cheat Sheet

See the code

README

RxSwift to Combine Cheatsheet

This is a Cheatsheet for RxSwift developers interested in Apple's new Combine framework.

It's based on the following blog post: https://medium.com/gett-engineering/rxswift-to-apples-combine-cheat-sheet-e9ce32b14c5b

Basics

RxSwiftCombine
Deployment TargetiOS 8.0+iOS 13.0+
Platforms supportediOS, macOS, tvOS, watchOS, LinuxiOS, macOS, tvOS, watchOS, UIKit for Mac ¹
SpecReactive Extensions (ReactiveX)Reactive Streams (+ adjustments)
Framework ConsumptionThird-partyFirst-party (built-in)
Maintained byOpen-Source / CommunityApple
UI BindingsRxCocoaSwiftUI ²

Core Components

RxSwiftCombineNotes
AnyObserverAnySubscriber
BehaviorRelay❌Simple wrapper around BehaviorSubject, could be easily recreated in Combine
BehaviorSubjectCurrentValueSubjectThis seems to be the type that holds @State under the hood
Completable❌
CompositeDisposable❌
ConnectableObservableTypeConnectablePublisher
DisposableCancellable
DisposeBagA collection of AnyCancellablesCall anyCancellable.store(in: &collection), where collection can be an array, a set, or any other RangeReplaceableCollection
DriverObservableObjectBoth guarantee no failure, but Driver guarantees delivery on Main Thread. In Combine, SwiftUI recreates the entire view hierarachy on the Main Thread, instead.
MaybeOptional.Publisher
ObservablePublisher
ObserverSubscriber
PublishRelay❌Simple wrapper around PublishSubject, could be easily recreated in Combine
PublishSubjectPassthroughSubject
ReplaySubject❌
ScheduledDisposable❌
SchedulerTypeScheduler
SerialDisposable❌
Signal❌
SingleDeferred + FutureFuture has to be wrapped in a Deferred, or its greedy as opposed to Single's laziness
SubjectTypeSubject
TestScheduler❌There doesn't seem to be an existing testing scheduler for Combine code

Operators

RxSwiftCombineNotes
allSatisfyallSatisfy
amb()❌
asObservable()eraseToAnyPublisher()
asObserver()❌
bind(to:)assign(to:on:)Assign uses a KeyPath which is really nice and useful. RxSwift needs a Binder / ObserverType to bind to.
bufferbuffer
catchcatch
catchAndReturnreplaceError(with:)
combineLatestcombineLatest, tryCombineLatest
compactMapcompactMap, tryCompactMap
concatappend, prepend
concatMap❌
containscontains
countcount
create❌Apple removed AnyPublisher with a closure in Xcode 11 beta 3 :-(
debouncedebounce
debugprint
deferredDeferred
delaydelay
delaySubscription❌
dematerialize❌
distinctUntilChangedremoveDuplicates, tryRemoveDuplicates
dohandleEvents
element(at:)output(at:)
emptyEmpty(completeImmediately: true)
enumerated❌
errorFail
filterfilter, tryFilter
firstfirst, tryFirst
first(where:)first(where:), tryFirst(where:)
flatMapflatMap
flatMapFirst❌
flatMapLatestswitchToLatest
from(optional:)Optional.Publisher(_ output:)
groupBy❌
ifEmpty(default:)replaceEmpty(with:)
ifEmpty(switchTo:)❌Could be achieved with composition - replaceEmpty(with: publisher).switchToLatest()
ignoreElementsignoreOutput
interval❌
justJust
last(where:)last(where:), tryLast(where:)
mapmap, tryMap
materialize❌
maxmax
mergemerge, tryMerge
merge(maxConcurrent:)flatMap(maxPublishers:)
minmin
multicastmulticast
neverEmpty(completeImmediately: false)
observe(on:)receive(on:)
ofSequence.publisherpublisher property on any Sequence or you can use Publishers.Sequence(sequence:) directly
publishmakeConnectable
range❌
reducereduce, tryReduce
refCountautoconnect
repeatElement❌
retry(when:)❌
retry, retry(3)retry, retry(3)
sample❌
scanscan, tryScan
shareshareThere’s no replay or scope in Combine. Could be “faked” with multicast.
skip(3)dropFirst(3)
skip(until:)drop(untilOutputFrom:)
skip(while:)drop(while:), tryDrop(while:)
startWithprepend
subscribesink
subscribe(on:)subscribe(on:)RxSwift uses Schedulers. Combine uses RunLoop, DispatchQueue, and OperationQueue.
take(1)prefix(1)
take(until:)prefix(untilOutputFrom:)
take(while:)prefix(while:), tryPrefix(while:)
takeLastlast
throttlethrottle
timeIntervalmeasureInterval
timeouttimeout
timerTimer.publish
toArray()collect()
windowcollect(Publishers.TimeGroupingStrategy)Combine has a TimeGroupingStrategy.byTimeOrCount that could be used as a window.
withLatestFrom❌
zipzip

Contributing

Add any data/operators to the appropriate CSV files in the Data folder, run bundle install and generate.rb.

Finally, commit the changes and submit a Pull Request.

apple
combine
reactive
reactive-programming
rxswift
swiftui

CombineCommunity/rxswift-to-combine-cheatsheet

RxSwift to Apple’s Combine Cheat Sheet

See the code

README

RxSwift to Combine Cheatsheet

This is a Cheatsheet for RxSwift developers interested in Apple's new Combine framework.

It's based on the following blog post: https://medium.com/gett-engineering/rxswift-to-apples-combine-cheat-sheet-e9ce32b14c5b

Basics

RxSwiftCombine
Deployment TargetiOS 8.0+iOS 13.0+
Platforms supportediOS, macOS, tvOS, watchOS, LinuxiOS, macOS, tvOS, watchOS, UIKit for Mac ¹
SpecReactive Extensions (ReactiveX)Reactive Streams (+ adjustments)
Framework ConsumptionThird-partyFirst-party (built-in)
Maintained byOpen-Source / CommunityApple
UI BindingsRxCocoaSwiftUI ²

Core Components

RxSwiftCombineNotes
AnyObserverAnySubscriber
BehaviorRelay❌Simple wrapper around BehaviorSubject, could be easily recreated in Combine
BehaviorSubjectCurrentValueSubjectThis seems to be the type that holds @State under the hood
Completable❌
CompositeDisposable❌
ConnectableObservableTypeConnectablePublisher
DisposableCancellable
DisposeBagA collection of AnyCancellablesCall anyCancellable.store(in: &collection), where collection can be an array, a set, or any other RangeReplaceableCollection
DriverObservableObjectBoth guarantee no failure, but Driver guarantees delivery on Main Thread. In Combine, SwiftUI recreates the entire view hierarachy on the Main Thread, instead.
MaybeOptional.Publisher
ObservablePublisher
ObserverSubscriber
PublishRelay❌Simple wrapper around PublishSubject, could be easily recreated in Combine
PublishSubjectPassthroughSubject
ReplaySubject❌
ScheduledDisposable❌
SchedulerTypeScheduler
SerialDisposable❌
Signal❌
SingleDeferred + FutureFuture has to be wrapped in a Deferred, or its greedy as opposed to Single's laziness
SubjectTypeSubject
TestScheduler❌There doesn't seem to be an existing testing scheduler for Combine code

Operators

RxSwiftCombineNotes
allSatisfyallSatisfy
amb()❌
asObservable()eraseToAnyPublisher()
asObserver()❌
bind(to:)assign(to:on:)Assign uses a KeyPath which is really nice and useful. RxSwift needs a Binder / ObserverType to bind to.
bufferbuffer
catchcatch
catchAndReturnreplaceError(with:)
combineLatestcombineLatest, tryCombineLatest
compactMapcompactMap, tryCompactMap
concatappend, prepend
concatMap❌
containscontains
countcount
create❌Apple removed AnyPublisher with a closure in Xcode 11 beta 3 :-(
debouncedebounce
debugprint
deferredDeferred
delaydelay
delaySubscription❌
dematerialize❌
distinctUntilChangedremoveDuplicates, tryRemoveDuplicates
dohandleEvents
element(at:)output(at:)
emptyEmpty(completeImmediately: true)
enumerated❌
errorFail
filterfilter, tryFilter
firstfirst, tryFirst
first(where:)first(where:), tryFirst(where:)
flatMapflatMap
flatMapFirst❌
flatMapLatestswitchToLatest
from(optional:)Optional.Publisher(_ output:)
groupBy❌
ifEmpty(default:)replaceEmpty(with:)
ifEmpty(switchTo:)❌Could be achieved with composition - replaceEmpty(with: publisher).switchToLatest()
ignoreElementsignoreOutput
interval❌
justJust
last(where:)last(where:), tryLast(where:)
mapmap, tryMap
materialize❌
maxmax
mergemerge, tryMerge
merge(maxConcurrent:)flatMap(maxPublishers:)
minmin
multicastmulticast
neverEmpty(completeImmediately: false)
observe(on:)receive(on:)
ofSequence.publisherpublisher property on any Sequence or you can use Publishers.Sequence(sequence:) directly
publishmakeConnectable
range❌
reducereduce, tryReduce
refCountautoconnect
repeatElement❌
retry(when:)❌
retry, retry(3)retry, retry(3)
sample❌
scanscan, tryScan
shareshareThere’s no replay or scope in Combine. Could be “faked” with multicast.
skip(3)dropFirst(3)
skip(until:)drop(untilOutputFrom:)
skip(while:)drop(while:), tryDrop(while:)
startWithprepend
subscribesink
subscribe(on:)subscribe(on:)RxSwift uses Schedulers. Combine uses RunLoop, DispatchQueue, and OperationQueue.
take(1)prefix(1)
take(until:)prefix(untilOutputFrom:)
take(while:)prefix(while:), tryPrefix(while:)
takeLastlast
throttlethrottle
timeIntervalmeasureInterval
timeouttimeout
timerTimer.publish
toArray()collect()
windowcollect(Publishers.TimeGroupingStrategy)Combine has a TimeGroupingStrategy.byTimeOrCount that could be used as a window.
withLatestFrom❌
zipzip

Contributing

Add any data/operators to the appropriate CSV files in the Data folder, run bundle install and generate.rb.

Finally, commit the changes and submit a Pull Request.

apple
combine
reactive
reactive-programming
rxswift
swiftui

Significant stargazers

Marcos Griselli

689 followers · starred Jun 2019

Wojciech Kulik

405 followers · starred Oct 2019

Michael Rebello

51 followers · starred Jul 2025

Julius Lundang

25 followers · starred Jul 2022