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.

From zero to hero with the Reactive extensions for JavaScript

76 views

Published on

Reactive and functional programming, you have probably heard the term mentioned before. It’s supposed to be really cool and a good practice. But what is reactive programming exactly and how to get started with it in JavaScript? And why does Angular start using the reactive extensions for JavaScript (RxJS) instead of standard promises?

In this presentation, Maurice is going to show you how to get started with RxJS, the JavaScript implementation of the ReactiveX library. You will learn why using RxJS is a great way of dealing with streams of events in an asynchronous and functional way.

Published in: Technology
  • Be the first to comment

From zero to hero with the Reactive extensions for JavaScript

  1. 1. From zero to hero with the Reactive Extensions forJavaScript Maurice de Beijer @mauricedb
  2. 2. Who am I?  Maurice de Beijer  The Problem Solver  MicrosoftAzure MVP  Freelance developer/instructor  Twitter: @mauricedb and @React_Tutorial  Web: http://www.TheProblemSolver.nl  E-mail: maurice.de.beijer@gmail.com 2
  3. 3. Topics  What is RxJS?  Why use it?  How to create observables.  Using operators with observables.
  4. 4. Observer pattern
  5. 5. Iterator pattern
  6. 6. Why?  Reactive programming.  Programming with asynchronous data streams.  Most actions are not standalone occurrences.  Example: A mouse click triggers an Ajax request which triggers a UI update.  RxJS composes these streams in a functional style.
  7. 7. Filtering data
  8. 8. With array functions
  9. 9. With RxJS
  10. 10. Timer based
  11. 11. With imperative code
  12. 12. With RxJS
  13. 13. Fetching data
  14. 14. With promises
  15. 15. With RxJS
  16. 16. Observables
  17. 17. The RxJS Observable  An Observable is the object that emits a stream of event.  The observer is the code that subscribes to the event stream.
  18. 18. A simple clock
  19. 19. Unsubscribing
  20. 20. Creating observables
  21. 21. Operators
  22. 22. RxJS operators  Operators are used to operate on the event stream between the source and the subscriber.  There are many operators for all sorts of purposes:  Transforming  Filtering  Combining  Error handling  Aggregate  …
  23. 23. RxMarbles Interactive diagrams of RxObservables
  24. 24. Events
  25. 25. Ajax
  26. 26. Retry failed requests
  27. 27. Retry with backing off
  28. 28. Combining streams  Streams can be combined in may ways:  Switching  Combine  Merging  Zip  …
  29. 29. Merge Example
  30. 30. Paint example
  31. 31. Conclusion  Reactive programming is very powerful.  Compose multiple asynchronous data streams.  Transform streams using operators as needed.  Retry failures.  Cancel subscriptions as needed.
  32. 32. Thank you Maurice de Beijer - @mauricedb

×