{"action":"created","issue":{"url":"https://api.github.com/repos/vuejs/vuex/issues/145","repository_url":"https://api.github.com/repos/vuejs/vuex","labels_url":"https://api.github.com/repos/vuejs/vuex/issues/145/labels{/name}","comments_url":"https://api.github.com/repos/vuejs/vuex/issues/145/comments","events_url":"https://api.github.com/repos/vuejs/vuex/issues/145/events","html_url":"https://github.com/vuejs/vuex/issues/145","id":148394959,"number":145,"title":"Vuex getters","user":{"login":"ruiposse","id":438467,"avatar_url":"https://avatars.githubusercontent.com/u/438467?v=3","gravatar_id":"","url":"https://api.github.com/users/ruiposse","html_url":"https://github.com/ruiposse","followers_url":"https://api.github.com/users/ruiposse/followers","following_url":"https://api.github.com/users/ruiposse/following{/other_user}","gists_url":"https://api.github.com/users/ruiposse/gists{/gist_id}","starred_url":"https://api.github.com/users/ruiposse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruiposse/subscriptions","organizations_url":"https://api.github.com/users/ruiposse/orgs","repos_url":"https://api.github.com/users/ruiposse/repos","events_url":"https://api.github.com/users/ruiposse/events{/privacy}","received_events_url":"https://api.github.com/users/ruiposse/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/vuejs/vuex/labels/discussion","name":"discussion","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2016-04-14T15:17:23Z","updated_at":"2016-08-22T08:47:56Z","closed_at":"2016-07-05T14:07:56Z","body":"Hi guys. There's been something on my mind lately about Vuex that I'll try my best to explain here.\r\n\r\nI understand that Vuex `getters` are meant to return a sub-set of the state and that's fine. I also kinda understand why they can't take arguments... because reasons (SSR) and stuff.\r\n\r\nOn a component, if I want to return, say, a product from the state I'd access it directly, something like `state.products[productId]` and that it would be fine.\r\n\r\nNow say I would like to return a product by `productName` instead and let's say I would do it by iterating on the product array state until I find it. This is still fine and I would create a `method` on the component to deal with it. If I would like to share `getProductByName` method, I would put it onto a `mixin` and everything would be alright.\r\n\r\nBut... Wouldn't it be nicer if Vuex could provide me with a way of creating a file of \"special\" `getters` so that everything state related (even just reading that state) would be managed on the \"Vuex side of things\" ?\r\n\r\nI think that literally what I'm saying is that Vuex could have a way of letting me pass arguments to \"`getters`\". Just for example sake, current `getters` would become `reducers` (because they return a sub-set of the state) and then the \"new\" `getters` would actually be able to take arguments to compute off. (I'm totally aware that renaming is not an option, since it would break compatibility, but hopefully it was useful for an argument sake) (also, sorry about `reducers` naming, because I didn't want to start a discussion on what Flux is not and what Vuex is 😄 ).\r\n\r\nAny thoughts ?"},"comment":{"url":"https://api.github.com/repos/vuejs/vuex/issues/comments/241349938","html_url":"https://github.com/vuejs/vuex/issues/145#issuecomment-241349938","issue_url":"https://api.github.com/repos/vuejs/vuex/issues/145","id":241349938,"user":{"login":"deiucanta","id":2116280,"avatar_url":"https://avatars.githubusercontent.com/u/2116280?v=3","gravatar_id":"","url":"https://api.github.com/users/deiucanta","html_url":"https://github.com/deiucanta","followers_url":"https://api.github.com/users/deiucanta/followers","following_url":"https://api.github.com/users/deiucanta/following{/other_user}","gists_url":"https://api.github.com/users/deiucanta/gists{/gist_id}","starred_url":"https://api.github.com/users/deiucanta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deiucanta/subscriptions","organizations_url":"https://api.github.com/users/deiucanta/orgs","repos_url":"https://api.github.com/users/deiucanta/repos","events_url":"https://api.github.com/users/deiucanta/events{/privacy}","received_events_url":"https://api.github.com/users/deiucanta/received_events","type":"User","site_admin":false},"created_at":"2016-08-22T08:47:56Z","updated_at":"2016-08-22T08:47:56Z","body":"@yyx990803 When using modules you can't get the route state inside the getter. For me, this is a MUST HAVE feature (allowing getters to have arguments)."}}
{"actor":{"display_login":"deiucanta"}}