{"action":"created","issue":{"url":"https://api.github.com/repos/rackt/redux-simple-router/issues/95","labels_url":"https://api.github.com/repos/rackt/redux-simple-router/issues/95/labels{/name}","comments_url":"https://api.github.com/repos/rackt/redux-simple-router/issues/95/comments","events_url":"https://api.github.com/repos/rackt/redux-simple-router/issues/95/events","html_url":"https://github.com/rackt/redux-simple-router/issues/95","id":121174239,"number":95,"title":"Support query params?","user":{"login":"kjbekkelund","id":5259,"avatar_url":"https://avatars.githubusercontent.com/u/5259?v=3","gravatar_id":"","url":"https://api.github.com/users/kjbekkelund","html_url":"https://github.com/kjbekkelund","followers_url":"https://api.github.com/users/kjbekkelund/followers","following_url":"https://api.github.com/users/kjbekkelund/following{/other_user}","gists_url":"https://api.github.com/users/kjbekkelund/gists{/gist_id}","starred_url":"https://api.github.com/users/kjbekkelund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjbekkelund/subscriptions","organizations_url":"https://api.github.com/users/kjbekkelund/orgs","repos_url":"https://api.github.com/users/kjbekkelund/repos","events_url":"https://api.github.com/users/kjbekkelund/events{/privacy}","received_events_url":"https://api.github.com/users/kjbekkelund/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":27,"created_at":"2015-12-09T06:46:30Z","updated_at":"2015-12-22T22:38:16Z","closed_at":null,"body":"This morning I've been playing around with how we _could_ support query params in `redux-simple-router` (just as a thought experiment).\r\n\r\nIn `history.listen` we receive a `Location`. With `pushPath` and `replacePath` we can change the API to accept `LocationDescriptor`s. However, with no way of creating a `LocationDescriptor` object from a `LocationDescriptor` string, it's difficult to support query params.\r\n\r\nHere's an example of the problem:\r\n\r\n```\r\npushPath('/foo?a=b')\r\n// store:\r\n{ location: '/foo?a=b' }\r\n\r\n\r\npushPath({ pathname: '/foo', query: { a: 'b' } })\r\n// store:\r\n{ location: { pathname: '/foo', query: { a: 'b' } } }\r\n\r\n\r\nhistory.push('/foo?a=b')\r\n// store:\r\n{ location: { pathname: '/foo', query: { a: 'b' } } }\r\n\r\n\r\n<Link to='/foo?a=b'>\r\n// store:\r\n{ location: { pathname: '/foo', query: { a: 'b' } } }\r\n```\r\n\r\nThe problem is of course that every time you `pushPath` you will get the exact `LocationDescriptor` you pass in into the store, but every time you `history.push` or `<Link>` you'll get an object. We then can't reliably support query params. (If you're very strict about always passing in a `LocationDescriptorObject` you would have query support, but that feels very fragile.)\r\n\r\nWe _can_ of course use `history.createLocation` right now, but it's most likely [no longer going to be public](https://github.com/rackt/history/pull/182) in `history` V2.\r\n\r\nTo support query params we need to be able to create a `LocationDescriptor` object both from a `LocationDescriptor` string and from a `Location`. We could then easily support query params, and we could also `deepEqual` check them without knowing about `query` or anything else that's actually part of the `LocationDescriptor` (which is how we stop cycles, #50). With a `createLocationDescriptor` (that always returns a `LocationDescriptorObject`) our code base would actually be simpler, and we would get query support for free.\r\n\r\nOkey, so some potential solutions:\r\n\r\n## Keep the solution we have now\r\n\r\nI.e. `path` and `state` in store, but change to accepting `LocationDescriptor` in `push` and `replace`. We don't support query params.\r\n\r\n## Verbatim `LocationDescriptor` in store\r\n\r\nWe have to make it _very_ clear that this is _either_ an object or a string. So it's most likely not very usable for people. We \"support\" query params, iff you're very strict about always passing in a `LocationDescriptorObject`. Fragile.\r\n\r\n## Always go through `history` \"before\" store\r\n\r\n```\r\npushPath\r\n-> UPDATE_PATH_INTERNAL action\r\n-> store.subscribe callback\r\n-> history.push\r\n-> history.listen callback\r\n-> UPDATE_PATH action\r\n-> store.subscribe callback where we break cycle\r\n```\r\n\r\nI.e. we don't trigger `UPDATE_PATH` immediately, but only within the `history.listen` callback. We would then reliably have a `LocationDescriptorObject` in the store, and we could therefore reliably support query params.\r\n\r\nThis is of course a more complex solution.\r\n\r\n# Conclusion\r\n\r\nIt was interesting going through the different solutions, but with `createLocation` going away and no `createLocationDescriptor` on the horizon I think it's best to just keep our current solution. I don't think it's worth the added complexity.\r\n\r\nMaybe someone else has ideas on how to solve this? Or maybe this is another case for keeping `history.createLocation` public? @jlongster @mjackson @taion @justingreenberg\r\n\r\n(Hopefully I haven't overlooked something very obvious :see_no_evil:)"},"comment":{"url":"https://api.github.com/repos/rackt/redux-simple-router/issues/comments/166752866","html_url":"https://github.com/rackt/redux-simple-router/issues/95#issuecomment-166752866","issue_url":"https://api.github.com/repos/rackt/redux-simple-router/issues/95","id":166752866,"user":{"login":"kjbekkelund","id":5259,"avatar_url":"https://avatars.githubusercontent.com/u/5259?v=3","gravatar_id":"","url":"https://api.github.com/users/kjbekkelund","html_url":"https://github.com/kjbekkelund","followers_url":"https://api.github.com/users/kjbekkelund/followers","following_url":"https://api.github.com/users/kjbekkelund/following{/other_user}","gists_url":"https://api.github.com/users/kjbekkelund/gists{/gist_id}","starred_url":"https://api.github.com/users/kjbekkelund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjbekkelund/subscriptions","organizations_url":"https://api.github.com/users/kjbekkelund/orgs","repos_url":"https://api.github.com/users/kjbekkelund/repos","events_url":"https://api.github.com/users/kjbekkelund/events{/privacy}","received_events_url":"https://api.github.com/users/kjbekkelund/received_events","type":"User","site_admin":false},"created_at":"2015-12-22T22:38:16Z","updated_at":"2015-12-22T22:38:16Z","body":"@ezekielchentnik I think it's likely we will become more coupled to react-router, not less. Also, the tagline has always been:\r\n\r\n> Let react-router do all the work"}}