{"action":"created","issue":{"url":"https://api.github.com/repos/rackt/redux/issues/797","labels_url":"https://api.github.com/repos/rackt/redux/issues/797/labels{/name}","comments_url":"https://api.github.com/repos/rackt/redux/issues/797/comments","events_url":"https://api.github.com/repos/rackt/redux/issues/797/events","html_url":"https://github.com/rackt/redux/issues/797","id":108178562,"number":797,"title":"Valid to dispatch multiple actions from an event handler?","user":{"login":"bfink13","id":1066236,"avatar_url":"https://avatars.githubusercontent.com/u/1066236?v=3","gravatar_id":"","url":"https://api.github.com/users/bfink13","html_url":"https://github.com/bfink13","followers_url":"https://api.github.com/users/bfink13/followers","following_url":"https://api.github.com/users/bfink13/following{/other_user}","gists_url":"https://api.github.com/users/bfink13/gists{/gist_id}","starred_url":"https://api.github.com/users/bfink13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bfink13/subscriptions","organizations_url":"https://api.github.com/users/bfink13/orgs","repos_url":"https://api.github.com/users/bfink13/repos","events_url":"https://api.github.com/users/bfink13/events{/privacy}","received_events_url":"https://api.github.com/users/bfink13/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-24T17:40:13Z","updated_at":"2015-09-24T18:10:03Z","closed_at":null,"body":"I'm in a situation where I'd like to dispatch two actions when a text box is blurred - I want to mark it as \"touched\" and also save it if there are no validation errors. I keep track of validation in the \"change\" reducer and only show the error message if a box has been \"touched\". I only want to save if there are no errors:\r\n\r\n    var item = this.props.items[index];\r\n    if (!item.error) {\r\n        this.actionCreators.saveItem(item.name, item.value);\r\n    }\r\n\r\n    this.actionCreators.touchItem(item.name);\r\n\r\nI'm using API middleware similar to the Real World example. It doesn't seem right to dispatch multiple actions in a single event handler since the second action will be working with state that is out of date.\r\n\r\nI feel like I'm missing something simple, as this seems to be a pretty common scenario. \r\n\r\nDoes anyone have recommendations?"},"comment":{"url":"https://api.github.com/repos/rackt/redux/issues/comments/143007754","html_url":"https://github.com/rackt/redux/issues/797#issuecomment-143007754","issue_url":"https://api.github.com/repos/rackt/redux/issues/797","id":143007754,"user":{"login":"bfink13","id":1066236,"avatar_url":"https://avatars.githubusercontent.com/u/1066236?v=3","gravatar_id":"","url":"https://api.github.com/users/bfink13","html_url":"https://github.com/bfink13","followers_url":"https://api.github.com/users/bfink13/followers","following_url":"https://api.github.com/users/bfink13/following{/other_user}","gists_url":"https://api.github.com/users/bfink13/gists{/gist_id}","starred_url":"https://api.github.com/users/bfink13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bfink13/subscriptions","organizations_url":"https://api.github.com/users/bfink13/orgs","repos_url":"https://api.github.com/users/bfink13/repos","events_url":"https://api.github.com/users/bfink13/events{/privacy}","received_events_url":"https://api.github.com/users/bfink13/received_events","type":"User","site_admin":false},"created_at":"2015-09-24T18:10:03Z","updated_at":"2015-09-24T18:10:03Z","body":"Thanks for the quick reply! \r\n\r\nIn this case I'm saving/touching onBlur. The code snippet above takes place within the onBlur handler. My example above is actually quite poor - here is an updated version:\r\n\r\n    handleBlur = (event) => {\r\n        var item = this.props.items[event.target.name];\r\n        if (!item.error) {\r\n            this.actionCreators.saveItem(event.target.name, item.value);\r\n        }\r\n\r\n        this.actionCreators.touchItem(event.target.name);\r\n    }\r\n\r\nDoes this make more sense?"}}