Skip to content

Instantly share code, notes, and snippets.

@williamhjcho
Last active December 11, 2019 10:26
Show Gist options
  • Save williamhjcho/4df6320b306ad02b2a619aac728ed50e to your computer and use it in GitHub Desktop.
Save williamhjcho/4df6320b306ad02b2a619aac728ed50e to your computer and use it in GitHub Desktop.

Rx Study Guide

Visual guide - RxMarbles

Observable

What is an Observable How to create an Observable:

  • just
  • of
  • from
  • create
  • deferred
  • timer

What is the difference between cold and hot Observables How does an Observable stream end

Observer/Subscriptions/Disposables

What is an Observer What is a subscription:

  • How to subscribe to an Observable?
  • If you subscribe to an Observable, does it always send the whole stream? (test this specially with create and deferred)
  • What is a Disposable?
  • What happens if a Disposable is disposed before the stream ends?
  • If nobody holds a Disposable instance, what happens?

Observable operations

What these operations do:

COMBINATION FILTERING MATHEMATICAL TRANSFORMATION UTILITY
combineLatest distinctUntilChanged count buffer delay
concat elementAt reduce concatMap delaySubscription
merge filter concatMapTo retry/retryWhen
startWith debounce map
withLatestFrom ignoreElements mapTo
zip last scan
sample
skip
skipUntil
skipWhile
take
takeLast
takeUntil
takeWhile
throttle

Special Kinds of Observables/Streams

PublishSubject, BehaviorSubject, Variable/BehaviorRelay: What are the differences between each other and normal Observables/Observers

Variable is in the process of being deprecated for BehaviorRelay, essentially they do the same thing

Traits - Specific kinds of Observables

What are, and what do they "guarantee":

  • Single
  • Maybe
  • Completable
  • ControlProperty
  • ControlEvent
  • Driver

What happens when you create a Single/Maybe and emit an next event twice?

What kind of errors do traits usually throw, and when?

How do you chain Observable sequences? What about Completables?

How do you apply/switch to different traits?

  • Observable -> Single | Maybe | Completable
  • Single -> Single | Maybe | Completable
  • Maybe -> Single | Maybe | Completable
  • Completable -> Single | Maybe | Completable

Some of the conversions above do not make sense, why?

What/where a Driver is mostly used for/on?

Schedulers

What kind of schedulers are there (First must understand Threads - Concurrent and Serial) What is subscribeOn and observeOn How is a computation scheduled to a specific thread?

Testing

If your test target exposes an Observable, what should be asserted of it?

Observables are essentially encapsulated asyncronous operations:

  • Do you need to assert the time the operation took?
  • Do you need to assert only the results? Then how do you block execution while waiting for the stream to end?
  • Do you need to assert which events are sent while modifying the source? Then how do you check the values received?

How would you create a testing hot/cold sequence? Look for TestScheduler after trying to answer, and check which would work better for your test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment