Improve example Documentation for Typeahead to make sense

I’m creating a typeahead that remotely calls an api every time someone types in the input, with a small delay after typing.

This code is from the bootstrap 4 typeahead example docs (Wikipedia example) makes no sense to me with all the .call and _do functions.

Angular Component

    search = (text$: Observable<string>) =>
     $, 300)),
               () => this.searching = true),
               (term) =>
                  () => this.searchFailed = false),
                  () => {
                  this.searchFailed = true;
         () => this.searching = false);


            <input mdInput [ngbTypeahead]="search"
               placeholder="Search by Name">
            <button type="submit" mdSuffix class="material-icons">search</button>
  1. What does this do in English? Right now I do not understand how to read this in normal terms and therefore cannot rewrite it for my needs.

  2. Can someone help me rewrite this in a more readable format? Such as using the chained sequence of promises, or anything else that makes more sense.

1 possible answer(s) on “Improve example Documentation for Typeahead to make sense

  1. I agree that in the current form the example is very hard to read… I’m going to revert the change that introduced .call(...) as we care about this library working with the closure compiler. We don’t build demo with closure so we don’t need to keep it closure-compatible. On top of this .call are needed only because of an issue in the closure compiler itself…