Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
a learning curve
a steep learning curve
you
a steep learning curve
superstar
a steep learning curve
you
you
superstar
a steep learning curve
you
superstar
a steep learning curve
me
RxJava in baby steps
@brwngrldev
asynchronous data streams
GPS Updates
Time
GPS Updates
Time
-36.34543, 3.23445
-36.34543, 3.23445

-36.24543, 3.23425

GPS Updates
Time
-36.34543, 3.23445

-36.24543, 3.23425

-35.34543, 3.13445
GPS Updates
Time
Time
server response
i want
toys!!!
Time
server response
Time
server response
toys
Time
i want
toys!!!
server response
Time
server response
Which of the following is an
asynchronous data stream?
A: click events
B: database access
C: server response
D: all of the...
A: click events
B: database access
C: server response
D: all of the above
Which of the following is an
asynchronous data s...
scientific Research
scientific Research
Data Transformation
Observable.just(5, 6, 7)
.map { ";-) ".repeat(it) }
.subscribe { println(it) }
Data Transformation
Observable.just(5, 6, 7)
.map { ";-) ".repeat(it) }
.subscribe { println(it) }
;-) ;-) ;-) ;-) ;-)
;-)...
chaining
Observable.just(5, 6, 7)
.map { ";-) ".repeat(it) }
.filter { it.length < 24 }
.subscribe { println(it) }
chaining
;-) ;-) ;-) ;-) ;-)
Observable.just(5, 6, 7)
.map { ";-) ".repeat(it) }
.filter { it.length < 24 }
.subscribe { p...
RxJava is. . . ?
A: the silver bullet
B: simply magic
C: pure voodoo
D: a library
RxJava is. . . ?
A: the silver bullet
B: simply magic
C: pure voodoo
D: a library
listOf(5, 6, 7)
.map { it * 5 }
.filter { it > 25 }
kotlin collections
listOf(5, 6, 7)
.map { it * 5 }
.filter { it > 25 }
kotlin collections
5 6 7
listOf(5, 6, 7)
.map { it * 5 }
.filter { it > 25 }
kotlin collections
5 6 7
map
25 30 35
listOf(5, 6, 7)
.map { it * 5 }
.filter { it > 25 }
kotlin collections
5 6 7
map
25 30 35
filter
30 35
listOf(5, 6, 7)
.asSequence()
.map { it * 5 }
.filter { it > 25 }
.toList()
kotlin sequences
kotlin sequences
listOf(5, 6, 7)
.asSequence()
.map { it * 5 }
.filter { it > 25 }
.toList()
5 6 7
5 6 7
map
filter
kotlin sequences
25
listOf(5, 6, 7)
.asSequence()
.map { it * 5 }
.filter { it > 25 }
.toList()
5 6 7
map
filter
kotlin sequences
25 30
30
listOf(5, 6, 7)
.asSequence()
.map { it * 5 }
.filter { it > 25 }
.toList()
5 6 7
map
filter
kotlin sequences
25 30 35
30 35
listOf(5, 6, 7)
.asSequence()
.map { it * 5 }
.filter { it > 25 }
.toList()
asynchronous data streams
RxJava
numbers
.map { it * 5 }
.filter { it > 25 }
.subscribe()
RxJava
numbers
.map { it * 5 }
.filter { it > 25 }
.subscribe()
5
25
map
filter
RxJava
numbers
.map { it * 5 }
.filter { it > 25 }
.subscribe()
5 6
map
filter
25 30
30
RxJava
numbers
.map { it * 5 }
.filter { it > 25 }
.subscribe()
5 6
map
filter
25 30
30 35
7
35
35
flexible
threading
schedulers
Observable.just(5, 6, 7)
.map { ";-) ".repeat(it) }
.subscribe { println(it) }
Observable.just(5, 6, 7)
.subscribeOn(Schedulers.io())
.map { ";-) ".repeat(it) }
.subscribe { println(it) }
The Basics
observable
The Basics
observableobserver
The Basics
operators observableobserver
observable
hot observable
Time
hot observable
Time
i want
hugs!!!
hot observable
Time
hugs
hot observable
Time
hugs hugs
hot observable
Time
hugs hugs hugs
Cold observable
Time
Cold observable
Time
Cold observable
Time
Cold observable
Time
hugs
Cold observable
Time
hugs hugs
Cold observable
Time
hugs hugs hugs
where?
Observable.create<Int> { subscriber -> }
Observable.create<Int> { subscriber -> }
Observable.just(item1, item2, item3)
Observable.create<Int> { subscriber -> }
Observable.just(item1, item2, item3)
Observable.interval(2, TimeUnit.SECONDS)
Observable.create<Int> { subscriber ->
}
Observable.create<Int> { subscriber ->
Logger.log("create")
Logger.log("complete")
}
Logger.log("done")
Observable.create<Int> { subscriber ->
Logger.log("create")
subscriber.onNext(5)
subscriber.onNext(6)
subscriber.onNext(7)...
Observable.create<Int> { subscriber ->
Logger.log("create")
subscriber.onNext(5)
subscriber.onNext(6)
subscriber.onNext(7)...
A: emit items
B: be cold
C: be hot
D: all of the above
Observables can. . .
A: emit items
B: be cold
C: be hot
D: all of the above
Observables can. . .
observer
interface Observer<T> {
fun onError(e: Throwable)
fun onComplete()
fun onNext(t: T)
fun onSubscribe(d: Disposable)
}
interface Observer<T> {
fun onError(e: Throwable)
fun onComplete()
fun onNext(t: T)
fun onSubscribe(d: Disposable)
}
interface Observer<T> {
fun onError(e: Throwable)
fun onComplete()
fun onNext(t: T)
fun onSubscribe(d: Disposable)
}
interface Observer<T> {
fun onError(e: Throwable)
fun onComplete()
fun onNext(t: T)
fun onSubscribe(d: Disposable)
}
interface Observer<T> {
fun onError(e: Throwable)
fun onComplete()
fun onNext(t: T)
fun onSubscribe(d: Disposable)
}
observer’s lifecycle
onSubscribe
observer’s lifecycle
onNext Normal
flow
onSubscribe
observer’s lifecycle
onComplete
Normal
flow
onSubscribe
onNext
observer’s lifecycle
onComplete onError
Normal
flow
onSubscribe
onNext
val observer = object : Observer<Int> {
override fun onError(e: Throwable) {
Logger.log(e)
}
override fun onComplete() {
L...
interface Consumer<T> {
fun accept(t: T)
}
val consumer = object : Consumer<Int> {
override fun accept(t: Int) {
Logger.log("next: $t")
}
}
val consumer = Consumer<Int> { t -> Logger.log("next: $t") }
obs.subscribe(consumer)
consumer
obs.subscribe(Consumer<Int> { t -> Logger.log("next: $t") })
consumer
obs.subscribe({ t -> Logger.log("next: $t") })
consumer
obs.subscribe{ t -> Logger.log("next: $t") }
consumer
obs.subscribe{ Logger.log("next: $it") }
consumer
A: have a lifecycle
B: always complete
C: Never Error
D: all of the above
Observers. . .
Observers. . .
A: have a lifecycle
B: always complete
C: Never Error
D: all of the above
operator
Time
Operator: map()
Time
Operator: map()
:-):-(
Time
Operator: map()
:-)
:-)
:-(
:-(
Time
Operator: map()
:-)
:-) :-)
:-(
:-(
:-(
Time
Operator: map()
:-)
:-) :-) :-)
:-(
:-(:-(:-(
Operator: map()
Observable.just(5, 6, 7)
.map { ";-) ".repeat(it) }
.subscribe { println(it) }
Operator: map()
;-) ;-) ;-) ;-) ;-)
;-) ;-) ;-) ;-) ;-) ;-)
;-) ;-) ;-) ;-) ;-) ;-) ;-)
Observable.just(5, 6, 7)
.map { ";...
Operator: map()
Observable.just(5, 6, 7)
.map(object: Function<Int, String> {
override fun apply(t: Int): String {
return ...
Operator: map()
Observable.just(5, 6, 7)
.map(object: Function<Int, String> {
override fun apply(t: Int): String {
return ...
Operator: map()
Observable.just(5, 6, 7)
.map(object: Function<Int, String> {
override fun apply(t: Int): String {
return ...
Operator: map()
Observable.just(5, 6, 7)
.map(object: Function<Int, String> {
override fun apply(t: Int): String {
return ...
.map(object: Function<Int, String> {
override fun apply(t: Int): String {
return ";-) ".repeat(t)
}
})
.map { ";-) ".repea...
what’s the output?
Observable.just(1, 2, 3)
.map { it * 2 }
.subscribe { println(it) }
A: 1, 2, 3
B: a, b, c
C: 2, 4, 6
D: 6, 2, 4
Observable.just(1, 2, 3)
.map { it * 2 }
.subscribe { println(it) }
what’s the...
Observable.just(1, 2, 3)
.map { it * 2 }
.subscribe { println(it) }
A: 1, 2, 3
B: a, b, c
C: 2, 4, 6
D: 6, 2, 4
what’s the...
what’s the output?
Observable.just(1, 2, 3)
.map { it * 2 }
.filter { it < 6 }
.subscribe { println(it) }
A: 2, 3, 1
B: 2, 4
C: 1, 2, 3
D: 6, 4
what’s the output?
Observable.just(1, 2, 3)
.map { it * 2 }
.filter { it < 6 }
.subs...
what’s the output?
Observable.just(1, 2, 3)
.map { it * 2 }
.filter { it < 6 }
.subscribe { println(it) }
A: 2, 3, 1
B: 2,...
Operator: flatmap()
via reactivex.io
Operator: flatmap()
via reactivex.io
item
Operator: flatmap()
via reactivex.io
item observable
Operator: flatmap()
Observable.just( , )
.flatMap( { Observable.just( ) } )
.subscribe { println(it) }
:-( :-(
time
flatmap
time
flatmap
:-(
time
flatmap
:-(
time
flatmap
:-(
time
flatmap
:-( :-(
time
flatmap
:-( :-(
time
flatmap
:-( :-(
time
flatmap
:-( :-(
Long Running
asynchronous
Operator: flatmap()
val users // Observable<User>
Operator: flatmap()
val users // Observable<User>
val posts: Observable<Post>
Operator: flatmap()
val users // Observable<User>
val posts: Observable<Post>
posts = users.flatMap { getUsersPosts(it.id)...
Operator: flatmap()
val users // Observable<User>
val posts: Observable<Post>
posts = users.flatMap { getUsersPosts(it.id)...
via reactivex.io
Flowable Maybe
backpressure
Disposable
Single
completable
should you use
rxjava?
like functional programing?
Process items asynchronously?
compose data?
handle errors gracefully?
should you use
rxjava?
should you use
rxjava?
like functional programing?
Process items asynchronously?
compose data?
handle errors gracefully?
it
depends
The Basics
operators observableobserver
you
www.adavis.info
@brwngrldev
• Reactive Programming on Android with RxJava (http://amzn.to/2yOAkxn)

• Reactive Programming with RxJava (http://amzn.to...
slide design:
@lauraemilyillustration
font: Elliot 6, fontSquirrel.com
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
RxJava In Baby Steps
Upcoming SlideShare
Loading in …5
×

RxJava In Baby Steps

7,139 views

Published on

Reactive Programming with RxJava has widely been adopted by both backend services and Android applications alike. Yet, the steep learning curve leaves many developers hesitant about adding it to their own Software tool belt. I was one such developer. Over the past two years, I’ve watched countless videos, read numerous blog posts and attended several conference talks on the subject. Yet, I often left each experience feeling only slightly more knowledgeable, but not quite empowered to start using RxJava in my apps. That’s not going to happen today!

In this talk, we’re going to cover the bare minimum concepts you need to grok, in order to start using RxJava today. In particular, we’re going to focus on:

The 3 O’s: Observable, Observer and Operator
The most common Operators: map(), flatMap(), and filter()
Understanding those Marble Diagrams

Reactive Programming is not going away any time soon. It’s a powerful way to create asynchronous, event-based applications. It allows developers the ability to craft applications that can easily combine multiple network calls, gracefully handle failures, all while providing a snappy user experience. I want everyone to feel comfortable with the basic concepts of RxJava. Today can be your first step...

Published in: Software

RxJava In Baby Steps

  1. 1. a learning curve
  2. 2. a steep learning curve
  3. 3. you a steep learning curve
  4. 4. superstar a steep learning curve you
  5. 5. you superstar a steep learning curve
  6. 6. you superstar a steep learning curve me
  7. 7. RxJava in baby steps @brwngrldev
  8. 8. asynchronous data streams
  9. 9. GPS Updates Time
  10. 10. GPS Updates Time -36.34543, 3.23445
  11. 11. -36.34543, 3.23445 -36.24543, 3.23425 GPS Updates Time
  12. 12. -36.34543, 3.23445 -36.24543, 3.23425 -35.34543, 3.13445 GPS Updates Time
  13. 13. Time server response
  14. 14. i want toys!!! Time server response
  15. 15. Time server response toys
  16. 16. Time i want toys!!! server response
  17. 17. Time server response
  18. 18. Which of the following is an asynchronous data stream? A: click events B: database access C: server response D: all of the above
  19. 19. A: click events B: database access C: server response D: all of the above Which of the following is an asynchronous data stream?
  20. 20. scientific Research
  21. 21. scientific Research
  22. 22. Data Transformation Observable.just(5, 6, 7) .map { ";-) ".repeat(it) } .subscribe { println(it) }
  23. 23. Data Transformation Observable.just(5, 6, 7) .map { ";-) ".repeat(it) } .subscribe { println(it) } ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-)
  24. 24. chaining Observable.just(5, 6, 7) .map { ";-) ".repeat(it) } .filter { it.length < 24 } .subscribe { println(it) }
  25. 25. chaining ;-) ;-) ;-) ;-) ;-) Observable.just(5, 6, 7) .map { ";-) ".repeat(it) } .filter { it.length < 24 } .subscribe { println(it) }
  26. 26. RxJava is. . . ? A: the silver bullet B: simply magic C: pure voodoo D: a library
  27. 27. RxJava is. . . ? A: the silver bullet B: simply magic C: pure voodoo D: a library
  28. 28. listOf(5, 6, 7) .map { it * 5 } .filter { it > 25 } kotlin collections
  29. 29. listOf(5, 6, 7) .map { it * 5 } .filter { it > 25 } kotlin collections 5 6 7
  30. 30. listOf(5, 6, 7) .map { it * 5 } .filter { it > 25 } kotlin collections 5 6 7 map 25 30 35
  31. 31. listOf(5, 6, 7) .map { it * 5 } .filter { it > 25 } kotlin collections 5 6 7 map 25 30 35 filter 30 35
  32. 32. listOf(5, 6, 7) .asSequence() .map { it * 5 } .filter { it > 25 } .toList() kotlin sequences
  33. 33. kotlin sequences listOf(5, 6, 7) .asSequence() .map { it * 5 } .filter { it > 25 } .toList() 5 6 7
  34. 34. 5 6 7 map filter kotlin sequences 25 listOf(5, 6, 7) .asSequence() .map { it * 5 } .filter { it > 25 } .toList()
  35. 35. 5 6 7 map filter kotlin sequences 25 30 30 listOf(5, 6, 7) .asSequence() .map { it * 5 } .filter { it > 25 } .toList()
  36. 36. 5 6 7 map filter kotlin sequences 25 30 35 30 35 listOf(5, 6, 7) .asSequence() .map { it * 5 } .filter { it > 25 } .toList()
  37. 37. asynchronous data streams
  38. 38. RxJava numbers .map { it * 5 } .filter { it > 25 } .subscribe()
  39. 39. RxJava numbers .map { it * 5 } .filter { it > 25 } .subscribe() 5 25 map filter
  40. 40. RxJava numbers .map { it * 5 } .filter { it > 25 } .subscribe() 5 6 map filter 25 30 30
  41. 41. RxJava numbers .map { it * 5 } .filter { it > 25 } .subscribe() 5 6 map filter 25 30 30 35 7 35 35
  42. 42. flexible threading
  43. 43. schedulers
  44. 44. Observable.just(5, 6, 7) .map { ";-) ".repeat(it) } .subscribe { println(it) }
  45. 45. Observable.just(5, 6, 7) .subscribeOn(Schedulers.io()) .map { ";-) ".repeat(it) } .subscribe { println(it) }
  46. 46. The Basics observable
  47. 47. The Basics observableobserver
  48. 48. The Basics operators observableobserver
  49. 49. observable
  50. 50. hot observable Time
  51. 51. hot observable Time i want hugs!!!
  52. 52. hot observable Time hugs
  53. 53. hot observable Time hugs hugs
  54. 54. hot observable Time hugs hugs hugs
  55. 55. Cold observable Time
  56. 56. Cold observable Time
  57. 57. Cold observable Time
  58. 58. Cold observable Time hugs
  59. 59. Cold observable Time hugs hugs
  60. 60. Cold observable Time hugs hugs hugs
  61. 61. where?
  62. 62. Observable.create<Int> { subscriber -> }
  63. 63. Observable.create<Int> { subscriber -> } Observable.just(item1, item2, item3)
  64. 64. Observable.create<Int> { subscriber -> } Observable.just(item1, item2, item3) Observable.interval(2, TimeUnit.SECONDS)
  65. 65. Observable.create<Int> { subscriber -> }
  66. 66. Observable.create<Int> { subscriber -> Logger.log("create") Logger.log("complete") } Logger.log("done")
  67. 67. Observable.create<Int> { subscriber -> Logger.log("create") subscriber.onNext(5) subscriber.onNext(6) subscriber.onNext(7) Logger.log("complete") } Logger.log("done")
  68. 68. Observable.create<Int> { subscriber -> Logger.log("create") subscriber.onNext(5) subscriber.onNext(6) subscriber.onNext(7) subscriber.onComplete() Logger.log("complete") } Logger.log("done")
  69. 69. A: emit items B: be cold C: be hot D: all of the above Observables can. . .
  70. 70. A: emit items B: be cold C: be hot D: all of the above Observables can. . .
  71. 71. observer
  72. 72. interface Observer<T> { fun onError(e: Throwable) fun onComplete() fun onNext(t: T) fun onSubscribe(d: Disposable) }
  73. 73. interface Observer<T> { fun onError(e: Throwable) fun onComplete() fun onNext(t: T) fun onSubscribe(d: Disposable) }
  74. 74. interface Observer<T> { fun onError(e: Throwable) fun onComplete() fun onNext(t: T) fun onSubscribe(d: Disposable) }
  75. 75. interface Observer<T> { fun onError(e: Throwable) fun onComplete() fun onNext(t: T) fun onSubscribe(d: Disposable) }
  76. 76. interface Observer<T> { fun onError(e: Throwable) fun onComplete() fun onNext(t: T) fun onSubscribe(d: Disposable) }
  77. 77. observer’s lifecycle onSubscribe
  78. 78. observer’s lifecycle onNext Normal flow onSubscribe
  79. 79. observer’s lifecycle onComplete Normal flow onSubscribe onNext
  80. 80. observer’s lifecycle onComplete onError Normal flow onSubscribe onNext
  81. 81. val observer = object : Observer<Int> { override fun onError(e: Throwable) { Logger.log(e) } override fun onComplete() { Logger.log("on complete") } override fun onNext(t: Int) { Logger.log("next: $t") } override fun onSubscribe(d: Disposable) { Logger.log("on subscribe") } }
  82. 82. interface Consumer<T> { fun accept(t: T) }
  83. 83. val consumer = object : Consumer<Int> { override fun accept(t: Int) { Logger.log("next: $t") } }
  84. 84. val consumer = Consumer<Int> { t -> Logger.log("next: $t") } obs.subscribe(consumer) consumer
  85. 85. obs.subscribe(Consumer<Int> { t -> Logger.log("next: $t") }) consumer
  86. 86. obs.subscribe({ t -> Logger.log("next: $t") }) consumer
  87. 87. obs.subscribe{ t -> Logger.log("next: $t") } consumer
  88. 88. obs.subscribe{ Logger.log("next: $it") } consumer
  89. 89. A: have a lifecycle B: always complete C: Never Error D: all of the above Observers. . .
  90. 90. Observers. . . A: have a lifecycle B: always complete C: Never Error D: all of the above
  91. 91. operator
  92. 92. Time Operator: map()
  93. 93. Time Operator: map() :-):-(
  94. 94. Time Operator: map() :-) :-) :-( :-(
  95. 95. Time Operator: map() :-) :-) :-) :-( :-( :-(
  96. 96. Time Operator: map() :-) :-) :-) :-) :-( :-(:-(:-(
  97. 97. Operator: map() Observable.just(5, 6, 7) .map { ";-) ".repeat(it) } .subscribe { println(it) }
  98. 98. Operator: map() ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) ;-) Observable.just(5, 6, 7) .map { ";-) ".repeat(it) } .subscribe { println(it) }
  99. 99. Operator: map() Observable.just(5, 6, 7) .map(object: Function<Int, String> { override fun apply(t: Int): String { return ";-) ".repeat(t) } }) .subscribe { println(it) }
  100. 100. Operator: map() Observable.just(5, 6, 7) .map(object: Function<Int, String> { override fun apply(t: Int): String { return ";-) ".repeat(t) } }) .subscribe { println(it) }
  101. 101. Operator: map() Observable.just(5, 6, 7) .map(object: Function<Int, String> { override fun apply(t: Int): String { return ";-) ".repeat(t) } }) .subscribe { println(it) }
  102. 102. Operator: map() Observable.just(5, 6, 7) .map(object: Function<Int, String> { override fun apply(t: Int): String { return ";-) ".repeat(t) } }) .subscribe { println(it) }
  103. 103. .map(object: Function<Int, String> { override fun apply(t: Int): String { return ";-) ".repeat(t) } }) .map { ";-) ".repeat(it) }
  104. 104. what’s the output? Observable.just(1, 2, 3) .map { it * 2 } .subscribe { println(it) }
  105. 105. A: 1, 2, 3 B: a, b, c C: 2, 4, 6 D: 6, 2, 4 Observable.just(1, 2, 3) .map { it * 2 } .subscribe { println(it) } what’s the output?
  106. 106. Observable.just(1, 2, 3) .map { it * 2 } .subscribe { println(it) } A: 1, 2, 3 B: a, b, c C: 2, 4, 6 D: 6, 2, 4 what’s the output?
  107. 107. what’s the output? Observable.just(1, 2, 3) .map { it * 2 } .filter { it < 6 } .subscribe { println(it) }
  108. 108. A: 2, 3, 1 B: 2, 4 C: 1, 2, 3 D: 6, 4 what’s the output? Observable.just(1, 2, 3) .map { it * 2 } .filter { it < 6 } .subscribe { println(it) }
  109. 109. what’s the output? Observable.just(1, 2, 3) .map { it * 2 } .filter { it < 6 } .subscribe { println(it) } A: 2, 3, 1 B: 2, 4 C: 1, 2, 3 D: 6, 4
  110. 110. Operator: flatmap() via reactivex.io
  111. 111. Operator: flatmap() via reactivex.io item
  112. 112. Operator: flatmap() via reactivex.io item observable
  113. 113. Operator: flatmap() Observable.just( , ) .flatMap( { Observable.just( ) } ) .subscribe { println(it) } :-( :-(
  114. 114. time flatmap
  115. 115. time flatmap :-(
  116. 116. time flatmap :-(
  117. 117. time flatmap :-(
  118. 118. time flatmap :-( :-(
  119. 119. time flatmap :-( :-(
  120. 120. time flatmap :-( :-(
  121. 121. time flatmap :-( :-(
  122. 122. Long Running asynchronous
  123. 123. Operator: flatmap() val users // Observable<User>
  124. 124. Operator: flatmap() val users // Observable<User> val posts: Observable<Post>
  125. 125. Operator: flatmap() val users // Observable<User> val posts: Observable<Post> posts = users.flatMap { getUsersPosts(it.id) }
  126. 126. Operator: flatmap() val users // Observable<User> val posts: Observable<Post> posts = users.flatMap { getUsersPosts(it.id) } posts.subscribe { println(it) }
  127. 127. via reactivex.io
  128. 128. Flowable Maybe backpressure Disposable Single completable
  129. 129. should you use rxjava?
  130. 130. like functional programing? Process items asynchronously? compose data? handle errors gracefully? should you use rxjava?
  131. 131. should you use rxjava? like functional programing? Process items asynchronously? compose data? handle errors gracefully?
  132. 132. it depends
  133. 133. The Basics operators observableobserver
  134. 134. you
  135. 135. www.adavis.info @brwngrldev
  136. 136. • Reactive Programming on Android with RxJava (http://amzn.to/2yOAkxn) • Reactive Programming with RxJava (http://amzn.to/2zQtqb5) • RxJava Playlist (https://goo.gl/9fw1Zv) • Learning RxJava for Android Devs (https://goo.gl/VWxFLK) • RxJava Video Course (https://caster.io/courses/rxjava) resources
  137. 137. slide design: @lauraemilyillustration font: Elliot 6, fontSquirrel.com

×