Add a widget for helper configuration
See original GitHub issueFollowing up on #1027, letting the user provide its own configuration for the internal search configuration using searchParmaters
can be confusing because it relies on the internal structure of the helper state which is poorly documented.
But the helper and the state are objects that can be used for this configuration much more easily. It is also much more straightforward as it doesn’t require knowledge of the structure but on using methods.
We could easily provide a widget that let the user access either the state or the helper. I think that using the state would be better as it contains more fine grained methods and also some that are not directly accessible on the helper, such as setFacets
/ setDisjunctiveFacets
. It is also documented.
The API could look like :
search.addWidget(instantsearch.widgets.configurator(function (state) {
return state.setFacets(state.facets.concat('myOtherFacet'))
.addFacetRefinement('myOtherFacet', 'a value');
}))
What do you think? @redox @vvo @pixelastic
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:11 (11 by maintainers)
Top GitHub Comments
We have two proposals: make a widget, add a configuration option (either in
instantsearch(options)
orstart(setState)
).The widget approach pros:
The configuration option pros:
The widget approach would be close to
react-instantsearch
, but the two libraries are quite different: instantsearch.js offers a static configuration whereas react-instantsearch is dynamic. Also react-instantsearch does not offer any access to the helper. That’s why it’s a requirement for react-instantsearch and not so for instantantsearch.js.This can be revisited, since we use
Configure
for react-instantsearch. There we decided on a widget/component, even though it’s not DOM.As @alexandremeunier noticed when using
Configure
, it isn’t immediately obvious why you need a component for that, and not do it on theInstantSearch
component. I think we decided on a component to keep a clear distinction between algolia/helper params and things used in instantsearch.