- Mastering Reactive JavaScript
- Erich de Souza Oliveira
- 520字
- 2021-07-09 20:33:10
A World Full of Changes - Reactive Extensions to the Rescue
In the previous chapter, you learned the very basics of functional reactive programming, using the bacon.js library. We discussed what is an observable and saw two different flavors of it in the bacon.js library (EventStream and Property). We also looked at how to create observables from common event sources (interval, array, or user input) and even from any other possible source ( using the fromBinder() method).
After an introduction to observables, we looked at how to subscribe to it. You can react to events, errors, or even detect the end of an observable when you subscribe to it. So, you learned how to create an observer for your observables.
One of the really important lessons from the previous chapter was the usage of diagrams to explain how observables and operators occur, along with text explanations and example code. Understanding diagrams is the key to understanding the behavior of operators and observables; you will see a lot of diagrams throughout the book. Read this section with special attention. Read it again in case you're not comfortable with it yet, but don't be afraid if it seems complicated (it seemed that way to me the first time I saw it). You will keep seeing it with text explanations and will eventually learn how it works.
The previous chapter added a lot of new concepts to your toolbox, and one of these was operators. The usage of operators to transform your events into something completely new gives you the taste of functional reactive programming and lets you see how powerful and composable it is. If you liked the initial operators you used, then be happy; we will see a lot more operators in the upcoming chapters. Operators are the backbone of functional reactive programming and they help you write cleaner, concise, and testable code with ease.
Finally, we saw the laziness of observables in the bacon.js library. We will talk about the behavior of observables in RxJS in this chapter, so don't worry.
This chapter will introduce you to the world of Reactive Extensions. In this book, we will base our implementation on RxJS. However, Reactive Extensions is an agnostic framework (this means it has implementations for several languages), so a lot of the concepts described here can be used in other platforms (such as RxJava, RxSwift, and so on). This makes learning Reactive Extensions (and functional reactive programming) really useful, as you can use it to improve your code in different platforms.
The focus in this chapter is to teach you the different types of observables possible in the RxJS world. You will see that they differ a little bit from the observables of bacon.js but are easy to use. You will also learn how to react to events in our observables using observers and how to finish your observers.
This chapter will cover the following points:
- The different types of observables in the context of Reactive Extensions and the difference between them
- Using the RxJS API to create observables
- Reacting to events in our observables
- Reacting to errors in our observables
- 大學計算機應用基礎實踐教程(Windows 7+Office 2013)
- 無蘋果不生活 OS X Mountain Lion隨身寶典
- Linux網絡操作系統與實訓(第三版)
- Haskell Financial Data Modeling and Predictive Analytics
- 新手易學:系統安裝與重裝
- 深入Linux內核架構與底層原理(第2版)
- 數據中心系統工程及應用
- Mobile First Design with HTML5 and CSS3
- Linux使用和管理指南:從云原生到可觀測性
- Hands-On UX Design for Developers
- Drupal 7 Cookbook
- Hadoop Real-World Solutions Cookbook
- 大學計算機應用基礎實踐教程(Windows 7+MS Office 2010)
- Less Web Development Essentials
- Windows 8玩全不求人