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.

Make search function provide a better API

See original GitHub issue

This is a feature for instantsearch.js V2 – breaking change

Right now, we have a function that can be given to the instantsearch factory called searchFunction. This function is given a helper that can’t be modified, only the search function can be really used. Instead we could only provide a single function search as a parameter.

API proposal

instantsearch({
  searchFunction: (search, searchParameters) => {
     search(searchParameters.setQuery(''));
  };
});

In this example, the function will prevent the query to be set.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
bobylitocommented, May 3, 2017

After using this method a few times, using the fake helper while wanting to change the values before doing a search feels terribly clunky. However JS has prototypal inheritance and we could leverage it to provide a lightweight helper that actually triggers the search.

New proposal would be:

instantsearch({
  searchFunction: (helper) => {
     helper.setQuery('new value').search());
  };
});

This means that it will feel like the original helper with the same interface and we won’t need to actually get the helper instance on the instantsearch object.

0reactions
bobylitocommented, Jun 8, 2017

We’ve implemented the latest proposal in the latest beta of instantsearch.js v2. It works fine except that now it poses problem for custom widget that want to bind on the help lifecycle as well. This is because of the behavior of an event emitter behavior as a prototype (with the use of immutable objects which don’t update their values in place). see #2176

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create a search interface with the Query API | Cloud Search
The Query API provides search and suggest methods for building a search interface or embedding search results in an application.
Read more >
Search API: Understanding and Using - Documentation
The search:search function is highly customizable, but by default it includes sensible settings that will provide good results for many applications.
Read more >
What to look for in a search API | Algolia
Search APIs are the backbone of a great user experience. Learn the important factors to consider when deciding on a search API solution....
Read more >
Boost Developer Experience with Great API Documentation ...
Providing great API search helps improve the developer experience with your product. Let's find out how you can build the ideal ...
Read more >
How To Create A Search Bar In JavaScript - YouTube
A search bar is something that nearly every application needs at some point, and luckily creating one is surprisingly easy.
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