Let's do another web example: typeahead searches. The usual setup is that there is some textbox, the user types in it, and the web page queries some API to provide ways of completing the search. The important thing is when and how to do the search and trying to avoid unnecessary calls to the backend server whenever possible. A (totally basic) HTML page could be as follows, and see Figure 11.4 later in this section:
<html> <head> <title>Cities search</title> <script type="text/javascript" src="rxjs.umd.js"></script> </head> <body> Find cities: <input type="text" id="myText" /> <br /> <h4>Some cities...</h4> <div id="myResults"></div> <script> // typeahead code goes here... </script> </body></html>
We have a single ...