RxBasicsKata

by sergiiz

sergiiz /RxBasicsKata

Practical challenges for RxJava learners

454 Stars 89 Forks Last release: Not found MIT License 23 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Practical challenges for RxJava learners

A set of simple code challenges to learn RxJava using JUnit tests as an acceptance criteria. Focused on some basic concepts and doesn't cover any Android topics yet.

"Solved" branch

Current implementation

Dependencies:

  • RxJava 2.1.7 
  • JUnit 4.12

Reactive types covered:

  • Observable: the heart of Rx, a class that emits a stream of data or events
  • Single : a version of an Observable that emits a single item or fails
  • Maybe: lazy emission pattern, can emit 1 or 0 items or an error signal

Operators covered:

  • map: transforms the items by applying a function to each item
  • flatMap: takes the emissions of one Observable and returns merged emissions in another Observable to take its place
  • filter: emits only those items from that pass a criteria (predicate test)
  • skip/take: suppress or takes the first n items 
  • all: determines whether all items meet some criteria
  • reduce: applies a function to each item sequentially, and emit the final value. For example, it can be used to sum up all emitted items
  • toMap: converts an Observable into another object or data structure
  • merge: combine multiple Observables into one by merging their emissions
  • sequenceEqual: determine whether two Observables emit the same sequence of items
  • test: returns TestObserver with current Observable subscribed
  • timeout: to handle timeouts, e.g. deliver some fallback data

Testing approach:

  • The set of test cases are defined in a separate java file
  • As a “receiver” of emitted test events we use TestObserver. It records events and allows to make assertions about them
  • All tests are failing when you just took them from the repo. This is expected behaviour. You should make tests pass by implementing the logic in CountriesServiceSolved class

Blog post

See my blog post at Medium for more details: https://proandroiddev.com/practical-challenges-for-rxjava-learners-1821c454de9.

Contribution

Pull requests and new code challenges are really welcome.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.