Slide 38
Slide 38 text
BOILERPLATE REMOVAL - COMPREHENSIONS
doFM(
/* A non-terminating Observable */
{ () -> state },
/* A terminating Observable */
{ current -> clicks.first() },
/* Other terminating Observables */
{ current, clicks ->
networkRequest.call(element.id)
.map(changes ->
currentState.applyDelta(changes) })
).subscribe(state)
‣ Replaces nested flatMap,
switchMap, and concatMap
‣ Improves readability
‣ Helps noticing subtle
errors like using toList() on
non-finite observables
https://github.com/pakoito/
RxComprehensions
doFM(), doSM(), and doCM()
Every nested depth receives the
result of all Observables above it
Uses a function returning an
Observable for each depth of
nesting: Func0, Func1, Func2…
Structurally, it splits use cases into
reusable functions with N == depth
parameters and 1 output
38