concept iterator in category rxjs

appears as: iterator, iterators, n iterator, iterator, An iterator
RxJS in Action

This is an excerpt from Manning's book RxJS in Action.

The goal of this chapter is to give a broad view of the topics you’ll be learning about in this book. We’ll focus on looking at the limitations of the current solutions and point you to the chapters that show how RxJS addresses them. Furthermore, you’ll learn how to shift your mindset to think in terms of streams, also known as functional sequences of events, which RxJS implements under the hood through the use of familiar patterns such as iterator and observer. Finally, we’ll explore the advantages of RxJS to write asynchronous code, minus the entanglement caused by using callbacks, which also scales to any amount of data. Understanding the differences between these two worlds is crucial, so let’s begin there.

Figure 2.5. Iterators abstract the traversal mechanism, whether a for or a while loop, so that processing any type of data is done in the exact same way.

Streams in RxJS also respect the Iterator interface, and subscribers of this stream will listen for all the events contained inside it. As you saw previously, iterators are great at decoupling the iteration mechanism and data being iterated over from the business logic. When data defines the control flow of the program, this is known as data-driven code.