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.
RxSwift
@ RxSwift
https://speakerdeck.com/bricklife/rxswiftfalseobserveontosubscribeonwoli-jie-suru
• RxMarbles
Hot
• RxSwift Operator
ReactiveX
(Driver …)
• Operator
• Hot / Cold
• RxSwift v2.5.0 (2016 7 master)
• 1
1
Operator
source
Sequence Map Filter
↑
Sequence Map Filter
↑
filter
filter
Filter
filter
source filter
Observable
map
Map
source
Map source Sequence
(Sequence Observable.of )
source
Filter source Map
source
Sequence Map Filter
source
source
Sequence Map Filter
source
source
source
Sequence Map Filter
source
source
create Operator source
• create, just, of, error, never create
Operator source
• map filter Operator
Hot subscribeOn/observ...
create Operator source
• Operator
create Operator
source
• source Observable
source ( ) subscribe
• ( )subscribe
Hot / Cold Operator
source
• create Operator Observable
source
source
Sequence Map Filter
source
2
Operator
Operator
Operator
• source subscribe
• source
Operator
Sequence Map Filter Observer
subscribe
Operator
subscribe
Sequence Map Filter Observer
subscribe subscribe
source subscribe
Operator
Sequence Map Filter Observer
on on on
Operator
subscribe
Sequence Map Filter Observer
subscribe subscribe
on on on
Operator
3
• source subscribe
• subscribe
• on
: Filter
: Filter
run subscribe
: Filter
sink source subscribe
: Filter
Sequence Map Filter Observer
subscribe
subscribe
: Filter
Sequence Map Filter Observer
subscribe subscribe
source subscribe
: Filter
: Filter
on source
: Filter
Next
: Filter
: Filter
: Filter
Sequence Map Filter Observer
on
source
: Filter
Sequence Map Filter Observer
on on
✌('ω'✌ ) ✌('ω')✌ ( ✌'ω')✌
3
• source subscribe
• subscribe
• on
Subject …
3
• source subscribe
• subscribe
• on
create Operator …
• subscribe
3
Sink / SinkIter
( ) Operator
• source subscribe
• source
( ) Operator
• source subscribe
• source
subscribe observer
Filter
Filter
Filter
Sink
Sink
• ( )source observer
• Filter FilterSink Map MapSink
Operator Sink
(subscribe )
Sequence Map Filter Observer
Filter
Sequence Map Filter Observer
subscribe run
subscribe(observer)
Filter
Sequence Map Filter Observer
subscribe(observer)
observer
Filter
Sequence Map Filter Observer
observer FilterSink
FilterSink(observer)
Filter
Sequence Map Filter Observer
FilterSink source subscribe
source.subscribe(FilterSink(observer))
Map
Sequence Map Filter Observer
source.subscribe(FilterSink(observer))
Map
Sequence Map Filter Observer
source.subscribe(FilterSink(observer))
observer FilterSink(observer)
Map
Sequence Map Filter Observer
MapSink(FilterSink(observer))
observer FilterSink
Map
Sequence Map Filter Observer
source.subscribe(MapSink(FilterSink(observer)))
MapSink source subscribe
(on )
MapSink
Sequence Map Filter Observer
MapSink(FilterSink(observer)).on(.Next(2))
MapSink
Sequence Map Filter Observer
selector
.Next(2) → .Next(4)
MapSink
Sequence Map Filter Observer
FilterSink(observer).on(.Next(4))
FilterSink
Sequence Map Filter Observer
FilterSink(observer).on(.Next(4))
FilterSink
Sequence Map Filter Observer
value % 4 == 0
FilterSink
Sequence Map Filter Observer
observer.on(.Next(4))
✌('ω'✌ ) ✌('ω')✌ ( ✌'ω')✌
subscribe(MapSink(FilterSink(observer)))
Sequence Map Filter Observer
subscribe(FilterSink(observer))
subscribe(observer)
...
Sequence Map Filter Observer
observer.on(.Next)
FilterSink(observer).on(.Next)
MapSink(FilterSink(observer)).on(.Next)
Sin...
SinkIter
SinkIter
• merge flatMap ( )
Observable<Observable<E>>
SinkIter
Observable<Observable<E>>
SinkIter
Observable<Observable<E>>
Observable
subscribe Sink
SinkIter
Observable<Observable<E>>
Observable
subscribe SinkIter
Cold Observable
Cold Observable
• subscribe
• subscribe
Just
Just
subscribe ….
Just
Cold
Cold
subscribe
Just Map Filter Observer
subscribe subscribe
on on on
BehaviorSubject
BehaviorSubject
•
subscribe
BehaviorSubject
BehaviorSubject
observer
BehaviorSubject
subscribe
BehaviorSubject
subscribe observer
BehaviorSubject
BehaviorSubject
on
BehaviorSubject
BehaviorSubject
Observer
✌('ω'✌ ) ✌('ω')✌ ( ✌'ω')✌
• Rx Operator
•
RxSwift コードリーディングの勘所@社内RxSwift勉強会
RxSwift コードリーディングの勘所@社内RxSwift勉強会
Upcoming SlideShare
Loading in …5
×

RxSwift コードリーディングの勘所@社内RxSwift勉強会

2,436 views

Published on

RxSwift コードリーディングの勘所@社内RxSwift勉強会

Published in: Engineering
  • Login to see the comments

RxSwift コードリーディングの勘所@社内RxSwift勉強会

  1. 1. RxSwift @ RxSwift
  2. 2. https://speakerdeck.com/bricklife/rxswiftfalseobserveontosubscribeonwoli-jie-suru
  3. 3. • RxMarbles Hot • RxSwift Operator ReactiveX (Driver …)
  4. 4. • Operator • Hot / Cold
  5. 5. • RxSwift v2.5.0 (2016 7 master) • 1
  6. 6. 1 Operator source
  7. 7. Sequence Map Filter ↑
  8. 8. Sequence Map Filter ↑
  9. 9. filter
  10. 10. filter Filter
  11. 11. filter source filter Observable
  12. 12. map Map
  13. 13. source Map source Sequence (Sequence Observable.of )
  14. 14. source Filter source Map
  15. 15. source Sequence Map Filter source
  16. 16. source Sequence Map Filter source source
  17. 17. source Sequence Map Filter source source
  18. 18. create Operator source • create, just, of, error, never create Operator source • map filter Operator Hot subscribeOn/observeOn source
  19. 19. create Operator source • Operator create Operator
  20. 20. source • source Observable source ( ) subscribe • ( )subscribe Hot / Cold Operator
  21. 21. source • create Operator Observable source source Sequence Map Filter source
  22. 22. 2 Operator
  23. 23. Operator Operator • source subscribe • source
  24. 24. Operator Sequence Map Filter Observer subscribe
  25. 25. Operator subscribe Sequence Map Filter Observer subscribe subscribe source subscribe
  26. 26. Operator Sequence Map Filter Observer on on on
  27. 27. Operator subscribe Sequence Map Filter Observer subscribe subscribe on on on
  28. 28. Operator 3 • source subscribe • subscribe • on
  29. 29. : Filter
  30. 30. : Filter run subscribe
  31. 31. : Filter sink source subscribe
  32. 32. : Filter Sequence Map Filter Observer subscribe subscribe
  33. 33. : Filter Sequence Map Filter Observer subscribe subscribe source subscribe
  34. 34. : Filter
  35. 35. : Filter on source
  36. 36. : Filter Next
  37. 37. : Filter
  38. 38. : Filter
  39. 39. : Filter Sequence Map Filter Observer on source
  40. 40. : Filter Sequence Map Filter Observer on on
  41. 41. ✌('ω'✌ ) ✌('ω')✌ ( ✌'ω')✌
  42. 42. 3 • source subscribe • subscribe • on
  43. 43. Subject … 3 • source subscribe • subscribe • on
  44. 44. create Operator … • subscribe
  45. 45. 3 Sink / SinkIter
  46. 46. ( ) Operator • source subscribe • source
  47. 47. ( ) Operator • source subscribe • source subscribe observer
  48. 48. Filter
  49. 49. Filter
  50. 50. Filter
  51. 51. Sink
  52. 52. Sink • ( )source observer • Filter FilterSink Map MapSink Operator Sink
  53. 53. (subscribe )
  54. 54. Sequence Map Filter Observer
  55. 55. Filter Sequence Map Filter Observer subscribe run subscribe(observer)
  56. 56. Filter Sequence Map Filter Observer subscribe(observer) observer
  57. 57. Filter Sequence Map Filter Observer observer FilterSink FilterSink(observer)
  58. 58. Filter Sequence Map Filter Observer FilterSink source subscribe source.subscribe(FilterSink(observer))
  59. 59. Map Sequence Map Filter Observer source.subscribe(FilterSink(observer))
  60. 60. Map Sequence Map Filter Observer source.subscribe(FilterSink(observer)) observer FilterSink(observer)
  61. 61. Map Sequence Map Filter Observer MapSink(FilterSink(observer)) observer FilterSink
  62. 62. Map Sequence Map Filter Observer source.subscribe(MapSink(FilterSink(observer))) MapSink source subscribe
  63. 63. (on )
  64. 64. MapSink Sequence Map Filter Observer MapSink(FilterSink(observer)).on(.Next(2))
  65. 65. MapSink Sequence Map Filter Observer selector .Next(2) → .Next(4)
  66. 66. MapSink Sequence Map Filter Observer FilterSink(observer).on(.Next(4))
  67. 67. FilterSink Sequence Map Filter Observer FilterSink(observer).on(.Next(4))
  68. 68. FilterSink Sequence Map Filter Observer value % 4 == 0
  69. 69. FilterSink Sequence Map Filter Observer observer.on(.Next(4))
  70. 70. ✌('ω'✌ ) ✌('ω')✌ ( ✌'ω')✌
  71. 71. subscribe(MapSink(FilterSink(observer))) Sequence Map Filter Observer subscribe(FilterSink(observer)) subscribe(observer) observer Sink source subscribe
  72. 72. Sequence Map Filter Observer observer.on(.Next) FilterSink(observer).on(.Next) MapSink(FilterSink(observer)).on(.Next) Sink observer
  73. 73. SinkIter
  74. 74. SinkIter • merge flatMap ( ) Observable<Observable<E>>
  75. 75. SinkIter Observable<Observable<E>>
  76. 76. SinkIter Observable<Observable<E>> Observable subscribe Sink
  77. 77. SinkIter Observable<Observable<E>> Observable subscribe SinkIter
  78. 78. Cold Observable
  79. 79. Cold Observable • subscribe • subscribe
  80. 80. Just
  81. 81. Just subscribe ….
  82. 82. Just
  83. 83. Cold
  84. 84. Cold subscribe Just Map Filter Observer subscribe subscribe on on on
  85. 85. BehaviorSubject
  86. 86. BehaviorSubject • subscribe
  87. 87. BehaviorSubject
  88. 88. BehaviorSubject observer
  89. 89. BehaviorSubject subscribe
  90. 90. BehaviorSubject subscribe observer
  91. 91. BehaviorSubject
  92. 92. BehaviorSubject on
  93. 93. BehaviorSubject
  94. 94. BehaviorSubject Observer
  95. 95. ✌('ω'✌ ) ✌('ω')✌ ( ✌'ω')✌
  96. 96. • Rx Operator •

×