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.

[urlSync] create widget

See original GitHub issue

This widget should be able to keep the url in sync with the helper state.

API

// Setting some parameters
instant.addWidget(
  instantsearch.widgets.urlSync({
    // Parameters to be serialized and read from the URL
    trackedParameters : [
      // Any parameters of the SearchParameters can be chosen. Most likely to be chosen : 
      "query",
      "page",
      "hitsPerPage",
      // Also the index, as it can be changed for sorting purpose but is not in the SearchParameters
      "index",
      // Facets can be set through the usage of different widgets. But the user don't know much about that, only that it is based on an attribute
      "facet:myAttribute",
      // For simplicity sake, we can choose to track all the facets.
      "facet:*"
    ],
    // Minimum time after which we do a new serialization of the parameters into the URL
    timeout : 1000,
    useHash : false // should the url use #
  })
);

But with the use of default parameters, using the url sync is as simple as that :

instant.addWidget(instantsearch.widgets.urlSync());

Lifecycle hooks

Init

The url sync needs to override the defaults parameter set by any other components. So it should always come last in the initialisation.

Update of the URL

The update should take place each time there is an update of the SearchParameters. I’m not sure that the render would be the best time to update, and would prefer having it on the change of the helper (or any lifecycle we could implement that would mirror that event)

We could use _.debounce with the trailing and leading set to true.

Previous work

There is already an initial implementation, that could be used for bootstraping this widget.

https://github.com/algolia/algolia-ui-kit/blob/master/src/setup/url.js

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
vvocommented, Sep 24, 2015

always bet on PHP

0reactions
redoxcommented, Sep 24, 2015

Just tested it on the Magento integration, and we had also all the refinements. I’m OK keeping p and q.

Wait, it seems to be caused by our PHP code actually 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom widget with URL sync - Open Q&A - Algolia Community
Hi guys, I am working on a project where an existing developer has created a custom widget for instantsearch.js.
Read more >
Updating URLSync to routing #3559 - algolia/instantsearch.js
For this case, it's the searchBox widget. Even if you don't use the UI of the searchBox it has to be mounted. We...
Read more >
Create Pre-formatted Pages - ODS Academy
Learn to create a mechanism in pages that will enables your data users to go from ... called "urlsync" — in page showcasing...
Read more >
algolia instantsearch.js searchBox widget indexName error
Ok, so it turns out that this is a bug between Safari and instantsearch.js. By changing this: var search = instantsearch({ //... urlSync: ......
Read more >
instantsearch.js - npm
instantsearch.js is a library of widgets to build high performance ... url sync if defined useHash: false } }); // add a widget...
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