Show Menu
Cheatography

RxSwift Operators Cheat Sheet by

RxSwift supported operators

Creating Observ­ables

asObse­rvable
convert various objects into Observ­ables
create
create an Observable from scratch
deferred
create an Observable for each subscr­iption
from (array)
convert an array into Observable
of
empty
emit no items; terminates normally
error
emit no items; terminates with an error
never
emit no items; does not terminate
interval
emit a sequence of integers spaced by a given time interval
just
emit a particular item
range
emit a particular range of sequential integers
repeat­Element
emit a particular item multiple times
timer
emit a particular item after a given delay

Combining Observ­ables

merge
combine multiple Observ­ables into one by merging their emissions
startWith
emit a specified sequence of items before others from source
switch­Latest
convert an Observable that emits Observ­ables into a single Observable that emits the items emitted by the most-r­ece­ntl­y-e­mitted of those Observ­ables
combin­eLatest
combine the latest item emitted by each Observable
zip
combine the emissions of multiple Observ­ables together

Observable Utility Operators

delayS­ubs­cri­ption
shift the emissions forward in time by a particular amount
do / doOnNext
register an action to take upon Observable lifecycle events
observeOn / observ­eSi­ngleOn
specify the Scheduler on which an observer will observe
subscribe
operate upon the emissions and notifi­cations from an Observable
subscr­ibeOn
specify the Scheduler on which an Observable will operate
timeout
abort when no item emitted during a specified span of time
using
create a disposable resource that has the same lifespan as the Observable
debug

Connec­table Observable Operators

multicast
publish
convert an ordinary Observable into a connec­table Observable
refCount
make a Connec­table Observable behave like an ordinary Observable
replay
ensure that all observers see the same sequence of emitted items
shareR­eplay
 

Transf­orming Observ­ables

buffer
period­ically gather items into bundles
flatMap
transform the items into Observ­ables and merge them into a single one
flatMa­pFirst
flatMa­pLatest
map
transform the items by an Observ­abl­app­lying a function to each item
scan
apply a function to each item sequen­tially, and emit each successive value
window
period­ically subdivide items into Observ­ables

Filtering Observ­ables

debounce / throttle
filters out items rapidly followed by another item
distin­ctU­nti­lCh­anged
suppress duplicate items
elementAt
emit only item n
filter
emit only those items that pass a predicate test
sample
emit the most recent items since the previous sampling
skip
suppress the first n items
take
emit only the first n items
takeLast
emit only the final n items
single
emit only the first item

Condit­ional and Boolean Operators

amb
emit all of the items from only the first to emit an item or notifi­cation
skipWhile
discard items until a specified condition becomes false
skipUntil
discard items until a second Observable emits an item
takeWhile
mirror items until a specified condition becomes false
takeUntil
discard any items after a second Observable emits an item or terminates

Error Handling Operators

catch
recover from error by continuing the sequence without error
retry
resubs­cribe to source when error
retryWhen

Mathem­atical and Aggregate Operators

concat
emit the emissions from two or more Observ­ables without interl­eaving them
reduce / aggregate
apply a function to each item sequen­tially, and emit the final value
toArray
convert an Observable into an array
   
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

            Swift Cheat Sheet by Rob Phillips
          Basic Cisco IOS Commands Cheat Sheet
          Cisco Switch Configuration Cheat Sheet