{"action":"created","issue":{"url":"https://api.github.com/repos/angular-redux/ng-redux/issues/139","repository_url":"https://api.github.com/repos/angular-redux/ng-redux","labels_url":"https://api.github.com/repos/angular-redux/ng-redux/issues/139/labels{/name}","comments_url":"https://api.github.com/repos/angular-redux/ng-redux/issues/139/comments","events_url":"https://api.github.com/repos/angular-redux/ng-redux/issues/139/events","html_url":"https://github.com/angular-redux/ng-redux/issues/139","id":243038663,"number":139,"title":"Correct action pattern to use bindActionCreator","user":{"login":"KamranAsif","id":2875524,"avatar_url":"https://avatars3.githubusercontent.com/u/2875524?v=4","gravatar_id":"","url":"https://api.github.com/users/KamranAsif","html_url":"https://github.com/KamranAsif","followers_url":"https://api.github.com/users/KamranAsif/followers","following_url":"https://api.github.com/users/KamranAsif/following{/other_user}","gists_url":"https://api.github.com/users/KamranAsif/gists{/gist_id}","starred_url":"https://api.github.com/users/KamranAsif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KamranAsif/subscriptions","organizations_url":"https://api.github.com/users/KamranAsif/orgs","repos_url":"https://api.github.com/users/KamranAsif/repos","events_url":"https://api.github.com/users/KamranAsif/events{/privacy}","received_events_url":"https://api.github.com/users/KamranAsif/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-14T15:57:17Z","updated_at":"2017-08-03T22:21:55Z","closed_at":null,"body":"I'm trying to use redux + angular in my application. I have my action defined as a service to get dependency injected services that I rely on for async requests.\r\n\r\nIn my view, I have to do store.dispatch(actionService.action()). I'd much prefer to use bindActionCreator to be able to call actionService.action().\r\n\r\nMy problem is that my actions are defined on their class, so the only thing I can do is:\r\n```\r\nlet actions = bindActionCreator({\r\n  foo1: actionService.foo, \r\n  foo2: actionService.foo2, .\r\n  ..\r\n});\r\n```\r\n\r\nIs there a better pattern to do this in angularjs?"},"comment":{"url":"https://api.github.com/repos/angular-redux/ng-redux/issues/comments/320105868","html_url":"https://github.com/angular-redux/ng-redux/issues/139#issuecomment-320105868","issue_url":"https://api.github.com/repos/angular-redux/ng-redux/issues/139","id":320105868,"user":{"login":"johanzhou8","id":7051842,"avatar_url":"https://avatars0.githubusercontent.com/u/7051842?v=4","gravatar_id":"","url":"https://api.github.com/users/johanzhou8","html_url":"https://github.com/johanzhou8","followers_url":"https://api.github.com/users/johanzhou8/followers","following_url":"https://api.github.com/users/johanzhou8/following{/other_user}","gists_url":"https://api.github.com/users/johanzhou8/gists{/gist_id}","starred_url":"https://api.github.com/users/johanzhou8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanzhou8/subscriptions","organizations_url":"https://api.github.com/users/johanzhou8/orgs","repos_url":"https://api.github.com/users/johanzhou8/repos","events_url":"https://api.github.com/users/johanzhou8/events{/privacy}","received_events_url":"https://api.github.com/users/johanzhou8/received_events","type":"User","site_admin":false},"created_at":"2017-08-03T22:21:55Z","updated_at":"2017-08-03T22:21:55Z","body":"Did you try to put your action creators object in the `connect` function? The `connect` function will wrap the action creators for you so that you can directly call the action.\r\n```\r\n//in the controller\r\nlet actions = {\r\n  foo1: actionService.foo, \r\n  foo2: actionService.foo2,\r\n};\r\nconst unsubscribe = $ngRedux.connect(this.mapStateToThis, actions)(this);\r\n\r\n//in the template\r\n//controller as ctrl\r\n<button ng-click='ctrl.foo1()'>Foo1</button>\r\n```\r\nFollowing links might be helpful:\r\n[The example code](https://github.com/angular-redux/ng-redux/blob/master/examples/async/containers/app.js#L14) and [Redux: Using mapDispatchToProps() Shorthand Notation](https://egghead.io/lessons/javascript-redux-using-mapdispatchtoprops-shorthand-notation)"}}
{"actor":{"display_login":"johanzhou8"}}