{"action":"created","issue":{"url":"https://api.github.com/repos/rackt/redux/issues/672","labels_url":"https://api.github.com/repos/rackt/redux/issues/672/labels{/name}","comments_url":"https://api.github.com/repos/rackt/redux/issues/672/comments","events_url":"https://api.github.com/repos/rackt/redux/issues/672/events","html_url":"https://github.com/rackt/redux/issues/672","id":104212042,"number":672,"title":"Actioncreator async dependencies","user":{"login":"jonaswindey","id":3637300,"avatar_url":"https://avatars.githubusercontent.com/u/3637300?v=3","gravatar_id":"","url":"https://api.github.com/users/jonaswindey","html_url":"https://github.com/jonaswindey","followers_url":"https://api.github.com/users/jonaswindey/followers","following_url":"https://api.github.com/users/jonaswindey/following{/other_user}","gists_url":"https://api.github.com/users/jonaswindey/gists{/gist_id}","starred_url":"https://api.github.com/users/jonaswindey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonaswindey/subscriptions","organizations_url":"https://api.github.com/users/jonaswindey/orgs","repos_url":"https://api.github.com/users/jonaswindey/repos","events_url":"https://api.github.com/users/jonaswindey/events{/privacy}","received_events_url":"https://api.github.com/users/jonaswindey/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-09-01T08:14:50Z","updated_at":"2015-09-01T15:59:21Z","closed_at":"2015-09-01T09:00:02Z","body":"I'm having some difficulties in making one of my actions depend on the other.\r\n\r\nSimple use case (in my actions.js)\r\n```\r\nexport function fetchInquiryAttributes() {\r\n  return (dispatch, getState) => {\r\n    if (getState().inquiries.inquiryAttributes.length === 0)\r\n      request\r\n        .get(constants.API + '/inquiryattributes')\r\n        .end((error, res) => {\r\n          if (error) debug('dev')(error)\r\n          else\r\n            dispatch({\r\n              type: constants.FETCH_INQUIRY_ATTRIBUTES,\r\n              inquiryAttributes: res.body.items\r\n            })\r\n        })\r\n  }\r\n}\r\n```\r\n```\r\nexport function fetchInquiry\r\n  (_id, options) {\r\n  return dispatch => {\r\n    if (_id) {\r\n      dispatch({\r\n        type: constants.FETCH_INQUIRY_START\r\n      })\r\n      request\r\n        .get(constants.API + '/inquiries/' + _id)\r\n        .end((error, res) => {\r\n          if (error) debug('dev')(error)\r\n          else dispatch({\r\n            type: constants.FETCH_INQUIRY,\r\n            inquiry: res.body\r\n          })\r\n        })\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nNow my question is, I want to be able to call fetchInquiry(id) but I also want to be sure that fetchInquiryAttributes() is called and dispatched first.\r\nI know I can wrap the content of fetchInquiryAttributes in a promise and call that, but is there a way to reuse the actioncreator instead and wait for the dispatch?\r\n\r\nI need to be able to call both fetchInquiryAttributes and fetchInquiry independently, but in the latter call it should only dispatch if the first has been dispatched. Does that make sense?"},"comment":{"url":"https://api.github.com/repos/rackt/redux/issues/comments/136769335","html_url":"https://github.com/rackt/redux/issues/672#issuecomment-136769335","issue_url":"https://api.github.com/repos/rackt/redux/issues/672","id":136769335,"user":{"login":"jonaswindey","id":3637300,"avatar_url":"https://avatars.githubusercontent.com/u/3637300?v=3","gravatar_id":"","url":"https://api.github.com/users/jonaswindey","html_url":"https://github.com/jonaswindey","followers_url":"https://api.github.com/users/jonaswindey/followers","following_url":"https://api.github.com/users/jonaswindey/following{/other_user}","gists_url":"https://api.github.com/users/jonaswindey/gists{/gist_id}","starred_url":"https://api.github.com/users/jonaswindey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonaswindey/subscriptions","organizations_url":"https://api.github.com/users/jonaswindey/orgs","repos_url":"https://api.github.com/users/jonaswindey/repos","events_url":"https://api.github.com/users/jonaswindey/events{/privacy}","received_events_url":"https://api.github.com/users/jonaswindey/received_events","type":"User","site_admin":false},"created_at":"2015-09-01T15:59:21Z","updated_at":"2015-09-01T15:59:21Z","body":"Thanks so much Dan, this was very helpful. Hats off for all your work for the community."}}