{"action":"created","issue":{"url":"https://api.github.com/repos/algolia/algoliasearch-helper-js/issues/273","labels_url":"https://api.github.com/repos/algolia/algoliasearch-helper-js/issues/273/labels{/name}","comments_url":"https://api.github.com/repos/algolia/algoliasearch-helper-js/issues/273/comments","events_url":"https://api.github.com/repos/algolia/algoliasearch-helper-js/issues/273/events","html_url":"https://github.com/algolia/algoliasearch-helper-js/issues/273","id":127202303,"number":273,"title":"Fix the reset point of the helper","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":[{"url":"https://api.github.com/repos/algolia/algoliasearch-helper-js/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-01-18T10:57:29Z","updated_at":"2016-01-25T15:10:37Z","closed_at":null,"body":"Sometimes we want to be able to fix a set of parameter in the helper. What we recommend now, it to set it programmatically when we initialize the helper. However if we reset the helper by clearRefinements or other methods, we might end up changing the initial value.\r\n\r\n### API proposal\r\n\r\n```js\r\nvar search = new AlgoliasearchHelper();\r\nsearch.addNumericRefinement('price', '=', 4);\r\nsearch.setCurrentPage(3);\r\n// price = 4, other > 4, page = 3\r\nsearch.pinState({\r\n  constants: [page]\r\n});\r\nsearch.addNumericRefinement('other', '>', 4);\r\nsearch.addNumericRefinement('price', '=', 5);\r\n// Changes the value, no problem\r\n// price = 5, other > 4, page 3\r\nsearch.setCurrentPage(3);\r\n// Can't be changed, (throw an error here?)\r\nsearch.clearRefinements();\r\n// price = 4, other undefined, page 3\r\nsearch.reset()\r\n// Revert back to the pinned state\r\n```\r\n\r\n### Behavior\r\n\r\nBy default, all the values can still be changed, only the reset/clear functions will have their behavior modified. However, we sometimes want to have certain properties fixed once and for all. The constants can be a SearchParameters field or a specific facet (much like the filter API)"},"comment":{"url":"https://api.github.com/repos/algolia/algoliasearch-helper-js/issues/comments/174537711","html_url":"https://github.com/algolia/algoliasearch-helper-js/issues/273#issuecomment-174537711","issue_url":"https://api.github.com/repos/algolia/algoliasearch-helper-js/issues/273","id":174537711,"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},"created_at":"2016-01-25T15:10:37Z","updated_at":"2016-01-25T15:10:37Z","body":"> I think the example is still a bit broken:\r\nErf true!\r\n\r\n\r\n\r\n> As for naming, just some randoms idea: freezeState, freezeSearchParameters, pinSearchParameters, resetState\r\n\r\nGreat! Keep them coming. There are nice things here. Making the reference to SearchParameters is very good I think!\r\n\r\nImplementation-wise I started to have a look and it can be tricky. We'll have to discuss :)"}}