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.

Add a widget for helper configuration

See original GitHub issue

Following 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
bobylitocommented, May 16, 2017

We have two proposals: make a widget, add a configuration option (either in instantsearch(options) or start(setState)).

The widget approach pros:

  • separate the logic into a separated element
  • does not add to the current API

The configuration option pros:

  • Much better control over the lifecycle
  • Close to the searchParameters approach
  • Make sense if it’s a one time configuration at the beginning

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.

1reaction
Haroenvcommented, Mar 15, 2017

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 the InstantSearch component. I think we decided on a component to keep a clear distinction between algolia/helper params and things used in instantsearch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Making a Configurable Widget - Apple Developer
To add configurable properties to your widget: Add a custom intent definition that defines the configurable properties to your Xcode project. Use an ......
Read more >
Custom Widget and Algolia Helper.js functions - Open Q&A
I'm creating a custom widget to pre-check items on load: this.search.addWidget({ init(options) { // clear previous facets if set with query string or...
Read more >
Add a dashboard widget - Azure DevOps | Microsoft Learn
Tutorial for creating a widget that you can then add to a dashboard in Azure DevOps or Team Foundation Server (TFS)
Read more >
Add Your Own Widgets to the Agent Workspace
To edit one of your existing widgets, click the widget icon and choose what you want to do from the drop-down menu. You...
Read more >
Introduction to widgets - Flutter documentation
Flutter widgets are built using a modern framework that takes inspiration from React. The central idea is that you build your UI out...
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