RxJS in practice: how to make a typeahead with streams!

August 2017
Link to Dev.to

What it is

Second of a series of articles I wrote about RxJS, a really interesting library for reactive programming in JavaScript.

Unlike the first article, this one was an actual example of a feature built with RxJS. The finished example can be found in this Pen.

To quickly explain the example, we build a stream of input that would post a new input one second after the user stops typing (lets call this the InputStream). Each time we receive a new input from InputStream, we make a request to Datamuse to get a list of suggestions for that input. We then get a list of responses, and from that a list of word recommendations from the user Input (which we call SuggestionsStream). We subscribe to SuggestionsStream to display a new list on the page of possible words every time we get a new list of suggestions.

Made proudly by Sammy: Finding your lack of sense of pride and accomplishment, disturbing.