Chapter 4. It’s about time you used RxJS
This chapter covers
- Understanding time in RxJS
- Using time as a new dimension of your programs
- Building observable streams with time
- Learning about RxJS operators like debounce and throttle
- Analyzing event data with buffering
Time is a tricky business. We spoke earlier about the challenges that exist when the code you write isn’t synchronous; it may have unpredictable wait times from one instruction to the next. We defined observables as infinite sequences of events, and now we add the last part of the puzzle to this definition—over time. The ancient Greek Heraclitus implied that time is always in motion, and so are observables.
Observables
are infinite sequences of events over time.
You can accurately measure the time a synchronous program takes by adding the execution time of its constituent functions, but this doesn’t hold for asynchronous programs because instructions aren’t linearly executed, as shown in figure 4.1.