Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Handle the URL Parameters #40

Closed
kokliKo opened this issue Apr 3, 2015 · 7 comments
Closed

Handle the URL Parameters #40

kokliKo opened this issue Apr 3, 2015 · 7 comments
Milestone

Comments

@kokliKo
Copy link
Contributor

kokliKo commented Apr 3, 2015

Have an optional way to:
Load the params of the state from URL hash
Set the URL hash when state changes

@bobylito
Copy link
Contributor

bobylito commented Apr 7, 2015

This could be handled by on top of the helper :)

@Jerska
Copy link
Member

Jerska commented Apr 13, 2015

I would find it quite handy to have this in the helper. An option locationSync defaulted to false would make sense to me, what do you think @bobylito ?

@vvo
Copy link
Contributor

vvo commented Apr 13, 2015

Some thoughts on this:

  1. We must ensure we do not end up with a module that is just a bag of unrelated helpers. Not saying this is the case right now, but anything named "helper" can go pretty bad if we do not pay attention like we do.
  2. If implemented, this should be off by default
  3. The read-from-url, set-to-url should only be exposed to browsers ("easy" with browserify)
  4. Should we automatically read and relaunch a search when hash change AND state changes: back button
  5. Maybe this belongs to a specific module/algolia-magic-search-input module

@bobylito bobylito added this to the v2 next milestone Apr 13, 2015
@Jerska
Copy link
Member

Jerska commented May 13, 2015

Okay, just to have this discussion in the right thread [ Beginning here : https://github.com//pull/74#issuecomment-101558428 ]

@jerskouille We don't need another function to do the initial setup of the state because the constructor of the helper takes as a third parameter the options, which is a partial object of the SearchParameters.
The override function is here to give you the ability to update the state in the same fashion without having to create a new instance of the helper. We want this because this will be tricky to propagate in an already setup application.
Here is an example of how I see the use of this feature :
https://github.com/algolia/algolia-ui-kit/blob/feature/url/src/index.js#L47-L66

With https://github.com/algolia/algolia-ui-kit/blob/feature/url/src/setup/url.js , that's kind of big for the small feature it adds. To me at least some of this logic should be in the helper, hence the "serialize/deserialize" approach which could even be useful with node.

require("algoliasearch-helper/src/SearchParameters");

Client-side, if you're not in a browserified environment, how do you access the SearchParameters constructor?
[Edit: I would assume this is linked to https://github.com//issues/76 ]

@bobylito
Copy link
Contributor

@jerskouille You can't and that's obviously an issue. Creating one now!

@vvo
Copy link
Contributor

vvo commented Jul 23, 2015

This will be done in instantsearch.js, we may have to add some methods not related to url sync but useful to it in the helper though.

@bobylito
Copy link
Contributor

Generic tools are now provided in 2.6.0 in the url namespace, and others (for the current state) are on the helper instance. https://github.com/algolia/algoliasearch-helper-js#url-helpers http://algolia.github.io/algoliasearch-helper-js/docs/algoliasearchHelper.module_url.html

Actual implementation must be done by a third party was it imply being based on a browser environment, and contains some opinion that we don't want to force on the user here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants