O'Reilly logo

Mastering Reactive JavaScript by Erich de Souza Oliveira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The flatMapLatest() operator

This operator is similar to the flatMap() operator, but it only propagates items from the most recently transformed observable.

Imagine a search as you type feature. In this feature, for every key stroke you will do a search and present the current result in the screen; if you are accessing external resources such as a database or an API, some searches can take more time than others, and the naive implementation of this search (using flatMap() for instance) might show wrong results. Look at this example:

  1. A search box to search names in a database.
  2. The user types the letter J and starts a search for all available names starting with the letter J.
  3. The user types the letter O and starts a search for all available ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required