question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve example Documentation for Typeahead to make sense

See original GitHub issue

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>) =>
      _do.call(
         switchMap.call(
            _do.call(distinctUntilChanged.call(
               debounceTime.call(text$, 300)),
               () => this.searching = true),
               (term) => _catch.call(
                  _do.call(this._service.search(term),
                  () => this.searchFailed = false),
                  () => {
                  this.searchFailed = true;
                  return of.call([]);
            })),
         () => this.searching = false);

HTML

          <md-input-container>
            <input mdInput [ngbTypeahead]="search"
               [(ngModel)]="model"
               [formControl]="lookupSubscriberControl"
               type="text"
               placeholder="Search by Name">
            <button type="submit" mdSuffix class="material-icons">search</button>
         </md-input-container>
  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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
pkozlowski-opensourcecommented, Jul 27, 2017

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…

0reactions
IAMtheIAMcommented, Jul 27, 2017

@pkozlowski-opensource Awesome, thanks for doing that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

12 Autocomplete Suggestion Design Best Practices
Poor autocomplete design can prevent customers from making purchases. These 12 best practices will create a smooth user experience and ...
Read more >
jQuery Typeahead Search Configuration - RunningCoder
Configure jQuery Typeahead Search plugin, learn about the options and what they can do to improve your search bar.
Read more >
Develop with Couchbase Full-Text Search & Node.js
Learn to create a UI typeahead that populates based on data from Couchbase Full-Text Search (FTS) service using Node.js, jQuery, ...
Read more >
Twitter Bootstrap typeaheads tutorial - w3resource
Introduction. In this tutorial, you will see how to create typeaheads using Twitter Bootstrap. typeaheads are very useful to supply hints or ...
Read more >
Cutting Edge - Type Ahead | Microsoft Learn
For this article, I'll clarify the basics of using typeahead in a realistic scenario using the version of typeahead you find on NuGet...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found