✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Fire callback when user is done typing (rather than every key press)

So this is my rudimentary attempt at a “typeahead” system for an app:

    @app.callback(
        Output(component_id='search_results', component_property='children'),
        [Input(component_id='band_search', component_property='value')]
    )
    def search_for_band(query_string):
        if len(query_string) > 2:
            band_search_results = requests.get(
                "https://musicbrainz.org/ws/2/artist?query={}&limit=10&fmt=json".format(query_string + '*')
            ).json()

            formatted_results = []
            for artist in band_search_results['artists']:
                formatted_results.append(
                    html.Span(children=[
                        dcc.Link(artist['name'], href=artist['id']),
                        html.Br()
                    ])
                )

    return formatted_results

This sends a GET request every key press. Is there a way to only send the request when a user is done updating the value in the “search box”?

Alternatively, I’m also open to suggestions on how to implement a better search interface entirely.

Coming soon, see https://github.com/plotly/dash-core-components/pull/326