Slide 1

Slide 1 text

kuncevic.dev 5 minutes introduction in to RxJS ⏰

Slide 2

Slide 2 text

kuncevic.dev ALIAKSEI KUNCEVIČ Independent Consultant https://twitter.com/kuncevic https://github.com/kuncevic https://linkedin.com/in/kuncevic

Slide 3

Slide 3 text

kuncevic.dev @kuncevic Angular Minsk (BY) Frontend Tech (AU) COMMUNITY Angular Workshop Angular Sydney (AU) TEACHING‍ kuncevic.dev

Slide 4

Slide 4 text

kuncevic.dev @kuncevic CREATOR Aurelia vs React vs Vue vs Svelte vs Ember vs Elm vs Angular frontendwatch.com

Slide 5

Slide 5 text

kuncevic.dev What is RxJS ?

Slide 6

Slide 6 text

kuncevic.dev Reactive programming (paradigm) Rx Extensions (library, e.g RxJX) Observer pattern (object)

Slide 7

Slide 7 text

kuncevic.dev Think of RxJS as 'Lodash' for handling asynchronous events.

Slide 8

Slide 8 text

kuncevic.dev When do we use Reactive Programming?

Slide 9

Slide 9 text

kuncevic.dev Use Cases ✅ DOM events ✅ HTTP calls ✅ WebSockets

Slide 10

Slide 10 text

kuncevic.dev

Slide 11

Slide 11 text

kuncevic.dev Rx on different platforms

Slide 12

Slide 12 text

kuncevic.dev Rx extensions for Languages ✅ Java: RxJava ✅ JavaScript: RxJS ✅ C#: Rx.NET ✅ C#(Unity): UniRx ✅ Scala: RxScala ✅ Clojure: RxClojure ✅ C++: RxCpp ✅ Lua: RxLua ✅ Ruby: Rx.rb ✅ Rust: rxRust ✅ Python: RxPY ✅ Go: RxGo ✅ Groovy: RxGroovy ✅ JRuby: RxJRuby ✅ Kotlin: RxKotlin ✅ Swift: RxSwift ✅ PHP: RxPHP ✅ Elixir: reaxive ✅ Dart: RxDart

Slide 13

Slide 13 text

kuncevic.dev Frontend Frameworks

Slide 14

Slide 14 text

kuncevic.dev Observable vs Promise Emits multiple values over period of time Emits only single value at a time Lazy (Cold). Observable is not called until we subscribe for it. Not Lazy (Hot).It is executed without calling then or catch Can be canceled by calling unsubscribe Not cancellable Supports operators like map, forEach, reduce, retry, retryWhen Operators are not available We can chain observables to handle complex logic on the streams We can use only then clause Predictable error handling Pushes errors down the chain

Slide 15

Slide 15 text

kuncevic.dev Observable Operators

Slide 16

Slide 16 text

kuncevic.dev Observable Operators 250+

Slide 17

Slide 17 text

kuncevic.dev Common RxJS operators Area Operators Creation from,fromEvent, of Combination combineLatest, concat, merge, zip, startWith , withLatestFrom Filtering debounceTime, distinctUntilChanged, filter, take, takeUntil Transformation bufferTime, concatMap, map, mergeMap, scan, switchMap Utility tap Multicasting share

Slide 18

Slide 18 text

kuncevic.dev pipe function

Slide 19

Slide 19 text

kuncevic.dev Combine streams

Slide 20

Slide 20 text

kuncevic.dev .subscribe() Observables are Lazy

Slide 21

Slide 21 text

kuncevic.dev Main Features ✅ Cancelable ✅ Predictable error handling ✅ Extensive list of operators ✅ Guaranteed teardown of resources ✅ Keeps you away from 'callback hell'

Slide 22

Slide 22 text

kuncevic.dev Who is using RxJS? ✅ Microsoft ✅ Google(YouTube) ✅ Sony (PlayStation) ✅ Netflix ✅ Canva ✅ Slack ✅ Your company?

Slide 23

Slide 23 text

kuncevic.dev Links https://github.com/ReactiveX/RxJS https://rxjs.dev https://rxjs.xyz https://rxviz.com https://github.com/vuejs/vue-rx https://github.com/ReactiveX/rxjs/issues/4740 https://github.com/reactjs/rfcs/pull/147 https://stackblitz.com/edit/typescript-djhuxu