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.

Reactive Programming and RxJS

587 views

Published on

Reactive Programming overview on RxJS example

Published in: Engineering
  • Be the first to comment

Reactive Programming and RxJS

  1. 1. Reactive Programming and RxJS by Denis Gorbunov
  2. 2. In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. wikipedia.org
  3. 3. Systems built as Reactive Systems are more flexible, loosely-coupled and scalable. This makes them easier to develop and amenable to change. They are significantly more tolerant of failure and when failure does occur they meet it with elegance rather than disaster. Reactive Systems are highly responsive, giving users effective interactive feedback. reactivemanifesto.org
  4. 4. reactivex.io Java: RxJava JavaScript: RxJS C#: Rx.NET C#(Unity): UniRx Scala: RxScala Clojure: RxClojure C++: RxCpp Ruby: Rx.rb Python: RxPY Groovy: RxGroovy JRuby: RxJRuby Kotlin: RxKotlin Swift: RxSwift PHP: RxPHP
  5. 5. reactivex.io Java: RxJava JavaScript: RxJS C#: Rx.NET C#(Unity): UniRx Scala: RxScala Clojure: RxClojure C++: RxCpp Ruby: Rx.rb Python: RxPY Groovy: RxGroovy JRuby: RxJRuby Kotlin: RxKotlin Swift: RxSwift PHP: RxPHP
  6. 6. ReactiveX is a combination of the best ideas from the Observer pattern, the Iterator pattern, and functional programming reactivex.io
  7. 7. Observable and Observer
  8. 8. RxJS: Operators ReactiveX provides a collection of operators with which you can filter, select, transform, combine, and compose Observables. This allows for efficient execution and composition.
  9. 9. RxJS: Operators • buffer • bufferCount • bufferTime • bufferToggle • bufferWhen • cache • catch • combineAll • combineLatest • concat • concatAll • concatMap • concatMapTo • create • debounce • debounceTime • defaultIfEmpty • distinctUntilCha nged • delay • delayWhen • do • every • empty • expand • filter • first • forkJoin • from • fromEvent • fromPromise • groupBy • ignoreElements • interval • last • let • map • mapTo • merge • mergeAll • mergeMap
  10. 10. RxJS: Operators • multicast • of • partition • pluck • publish • race • range • retry • retryWhen • sample • share • single • skip • skipUntil • skipWhile • startWith • take • takeUntil • takeWhile • throttle • throttleTime • throw • timer • toPromise • scan • switchMap • window • windowCount • windowTime • windowToggle • windowWhen • withLatestFrom • zip
  11. 11. map rxmarbles.com
  12. 12. switchMap
  13. 13. combineLatest rxmarbles.com
  14. 14. debounce rxmarbles.com
  15. 15. filter rxmarbles.com
  16. 16. find rxmarbles.com
  17. 17. reduce rxmarbles.com
  18. 18. scan rxmarbles.com
  19. 19. takeUntil rxmarbles.com
  20. 20. merge rxmarbles.com
  21. 21. distinct rxmarbles.com
  22. 22. distinctUntilChanged rxmarbles.com
  23. 23. Subject
  24. 24. Subject
  25. 25. Subject
  26. 26. Subject
  27. 27. Subject
  28. 28. Hot and Cold Observables medium.com/@benlesh Observables are functions that tie an observer to a producer.
  29. 29. RxJS: Observable and Observer
  30. 30. Hot and Cold Observables COLD is when your observable creates the producer medium.com/@benlesh
  31. 31. Hot and Cold Observables COLD is when your observable creates the producer HOT is when your observable closes over the producer medium.com/@benlesh
  32. 32. Hot and Cold Observables COLD is when your observable creates the producer HOT is when your observable closes over the producer medium.com/@benlesh
  33. 33. Unsubscribe
  34. 34. Unsubscribe medium.com/@benlesh • take(n): emits N values before stopping the observable. • takeWhile(predicate): tests the emitted values against a predicate, if it returns `false`, it will complete. • first(): emits the first value and completes. • first(predicate): checks each value against a predicate function, if it returns `true`, the emits that value and completes.

×