{"action":"created","issue":{"url":"https://api.github.com/repos/vuejs/vuex/issues/526","repository_url":"https://api.github.com/repos/vuejs/vuex","labels_url":"https://api.github.com/repos/vuejs/vuex/issues/526/labels{/name}","comments_url":"https://api.github.com/repos/vuejs/vuex/issues/526/comments","events_url":"https://api.github.com/repos/vuejs/vuex/issues/526/events","html_url":"https://github.com/vuejs/vuex/issues/526","id":195787982,"number":526,"title":"The need for getters with payload","user":{"login":"andreiglingeanu","id":2979628,"avatar_url":"https://avatars.githubusercontent.com/u/2979628?v=3","gravatar_id":"","url":"https://api.github.com/users/andreiglingeanu","html_url":"https://github.com/andreiglingeanu","followers_url":"https://api.github.com/users/andreiglingeanu/followers","following_url":"https://api.github.com/users/andreiglingeanu/following{/other_user}","gists_url":"https://api.github.com/users/andreiglingeanu/gists{/gist_id}","starred_url":"https://api.github.com/users/andreiglingeanu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreiglingeanu/subscriptions","organizations_url":"https://api.github.com/users/andreiglingeanu/orgs","repos_url":"https://api.github.com/users/andreiglingeanu/repos","events_url":"https://api.github.com/users/andreiglingeanu/events{/privacy}","received_events_url":"https://api.github.com/users/andreiglingeanu/received_events","type":"User","site_admin":false},"labels":[{"id":442396678,"url":"https://api.github.com/repos/vuejs/vuex/labels/2.0","name":"2.0","color":"f9d0c4","default":false},{"id":397652763,"url":"https://api.github.com/repos/vuejs/vuex/labels/proposal","name":"proposal","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-15T11:59:09Z","updated_at":"2016-12-15T12:40:47Z","closed_at":null,"body":"Let me state right from the beginning, that's a feature request.\r\n\r\nI saw the discussion inside #52, especially quoting @yyx990803:\r\n\r\n> Why are you expecting payload inside getters? Computed getters do not take any arguments.\r\n\r\n<hr>\r\n\r\nThe thing is that I'm having a couple of use cases where being able to pass _payload_ to getters would be _very_ handy. I know, they're technically not functions thus you can't pass any arguments to them.\r\n\r\nRight now, I'm forced to extract all of my logic in functions that accept current state as the first argument and payload as the second one (I'm naming them `helpers`, to be specific). I'm forced to do this often, practically every app I used to work on has the need of getters with some payload. \r\n\r\nIt would be nice if vuex will adapt this pattern into itself, I'm seeing its usage as follows:\r\n\r\n```javascript\r\n\r\nnew Vuex.Store({\r\n  helpers: {\r\n    // type here is similar to what we have for mutations\r\n    GET_SOME_DATA (state, { id, type }) {\r\n      return my_awesome_computation(state, id);\r\n    }\r\n  }\r\n})\r\n\r\n// somewhere in my components\r\nvm.$store.extract({type: 'GET_SOME_DATA', id: 1});\r\n// or\r\nvm.$store.extract('GET_SOME_DATA', {id: 1});\r\n\r\n```\r\n\r\nThe most important thing is that they'll be integrated with the modules system vuex has, and that's most convenient thing to have.\r\n\r\nLet me know what do you think?\r\n\r\nI can even try my hand around getting a PR for you guys, if you approve my idea."},"comment":{"url":"https://api.github.com/repos/vuejs/vuex/issues/comments/267318320","html_url":"https://github.com/vuejs/vuex/issues/526#issuecomment-267318320","issue_url":"https://api.github.com/repos/vuejs/vuex/issues/526","id":267318320,"user":{"login":"sotaan","id":9435918,"avatar_url":"https://avatars.githubusercontent.com/u/9435918?v=3","gravatar_id":"","url":"https://api.github.com/users/sotaan","html_url":"https://github.com/sotaan","followers_url":"https://api.github.com/users/sotaan/followers","following_url":"https://api.github.com/users/sotaan/following{/other_user}","gists_url":"https://api.github.com/users/sotaan/gists{/gist_id}","starred_url":"https://api.github.com/users/sotaan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sotaan/subscriptions","organizations_url":"https://api.github.com/users/sotaan/orgs","repos_url":"https://api.github.com/users/sotaan/repos","events_url":"https://api.github.com/users/sotaan/events{/privacy}","received_events_url":"https://api.github.com/users/sotaan/received_events","type":"User","site_admin":false},"created_at":"2016-12-15T12:40:47Z","updated_at":"2016-12-15T12:40:47Z","body":"It seems that what you asking for is a reducer feature."}}
{"actor":{"display_login":"sotaan"}}