Make search function provide a better API
See original GitHub issueThis 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:
- Created 7 years ago
- Comments:8 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:
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.
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