{"action":"created","issue":{"url":"https://api.github.com/repos/algolia/algoliasearch-helper-js/issues/203","labels_url":"https://api.github.com/repos/algolia/algoliasearch-helper-js/issues/203/labels{/name}","comments_url":"https://api.github.com/repos/algolia/algoliasearch-helper-js/issues/203/comments","events_url":"https://api.github.com/repos/algolia/algoliasearch-helper-js/issues/203/events","html_url":"https://github.com/algolia/algoliasearch-helper-js/issues/203","id":105316686,"number":203,"title":"Provide a set of utility methods to help handling URLs","user":{"login":"bobylito","id":393765,"avatar_url":"https://avatars.githubusercontent.com/u/393765?v=3","gravatar_id":"","url":"https://api.github.com/users/bobylito","html_url":"https://github.com/bobylito","followers_url":"https://api.github.com/users/bobylito/followers","following_url":"https://api.github.com/users/bobylito/following{/other_user}","gists_url":"https://api.github.com/users/bobylito/gists{/gist_id}","starred_url":"https://api.github.com/users/bobylito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobylito/subscriptions","organizations_url":"https://api.github.com/users/bobylito/orgs","repos_url":"https://api.github.com/users/bobylito/repos","events_url":"https://api.github.com/users/bobylito/events{/privacy}","received_events_url":"https://api.github.com/users/bobylito/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2015-09-08T07:17:31Z","updated_at":"2015-09-09T09:57:07Z","closed_at":null,"body":"As we continue the development of the instantsearch.js, we need to provide a set of utility methods on the helper to make saving and restoring a search state easily (see [related issue in the instant search project](https://github.com/algolia/instantsearch.js/issues/17)). We will need to provide 3 methods on the helper : \r\n\r\n - one that creates a plain javascript object with only the specified subset of parameters from the current search state. This one could be implemented as specific behavior of the current getState method.\r\n - two that will serialize and deserialize a given subset of parameters and transform them into a query string form\r\n\r\nThe format to specify the subset is : \r\n```js\r\n[\r\n  // Any parameters of the SearchParameters can be chosen. Most likely to be chosen : \r\n  \"query\",\r\n  \"page\",\r\n  \"hitsPerPage\",\r\n  // Also the index, as it can be changed for sorting purpose but is not in the SearchParameters\r\n  \"index\",\r\n  // 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\r\n  \"attribute:myAttribute\",\r\n  // For simplicity sake, we can choose to track all the facets.\r\n  \"attribute:*\"\r\n]\r\n```\r\n\r\n## API proposal\r\n\r\n```js\r\nvar filters = [\"numeric:price\", \"facet:category\", \"query\"]\r\nhelper.getState(filters);\r\nhelper.getStateAsQueryString(filters, moreAttributes);\r\nhelper.setStateFromQueryString(queryString, filters);\r\n```\r\n\r\nUpdate : remove the queryString() factory method and use only plain methods"},"comment":{"url":"https://api.github.com/repos/algolia/algoliasearch-helper-js/issues/comments/138860783","html_url":"https://github.com/algolia/algoliasearch-helper-js/issues/203#issuecomment-138860783","issue_url":"https://api.github.com/repos/algolia/algoliasearch-helper-js/issues/203","id":138860783,"user":{"login":"vvo","id":123822,"avatar_url":"https://avatars.githubusercontent.com/u/123822?v=3","gravatar_id":"","url":"https://api.github.com/users/vvo","html_url":"https://github.com/vvo","followers_url":"https://api.github.com/users/vvo/followers","following_url":"https://api.github.com/users/vvo/following{/other_user}","gists_url":"https://api.github.com/users/vvo/gists{/gist_id}","starred_url":"https://api.github.com/users/vvo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vvo/subscriptions","organizations_url":"https://api.github.com/users/vvo/orgs","repos_url":"https://api.github.com/users/vvo/repos","events_url":"https://api.github.com/users/vvo/events{/privacy}","received_events_url":"https://api.github.com/users/vvo/received_events","type":"User","site_admin":false},"created_at":"2015-09-09T09:57:07Z","updated_at":"2015-09-09T09:57:07Z","body":"> My point is: to avoid naming conflicts with already existing variables in query strings, we should use only one\r\n\r\nThat's a good idea yes I like it. I hope that's feasible.\r\n\r\nWe can still use https://github.com/hapijs/qs, we will need to do (pseudo code) `aa-state=qs(state)`.\r\n\r\nAnd then all we need to provide is the `aa-state` token as a parameter (that's the prefix).\r\n\r\n thoughts @bobylito?"}}