{"action":"created","issue":{"url":"https://api.github.com/repos/jeffbski/redux-logic/issues/88","repository_url":"https://api.github.com/repos/jeffbski/redux-logic","labels_url":"https://api.github.com/repos/jeffbski/redux-logic/issues/88/labels{/name}","comments_url":"https://api.github.com/repos/jeffbski/redux-logic/issues/88/comments","events_url":"https://api.github.com/repos/jeffbski/redux-logic/issues/88/events","html_url":"https://github.com/jeffbski/redux-logic/issues/88","id":284580704,"node_id":"MDU6SXNzdWUyODQ1ODA3MDQ=","number":88,"title":"wait for dispatch to complete","user":{"login":"naorye","id":2873571,"node_id":"MDQ6VXNlcjI4NzM1NzE=","avatar_url":"https://avatars3.githubusercontent.com/u/2873571?v=4","gravatar_id":"","url":"https://api.github.com/users/naorye","html_url":"https://github.com/naorye","followers_url":"https://api.github.com/users/naorye/followers","following_url":"https://api.github.com/users/naorye/following{/other_user}","gists_url":"https://api.github.com/users/naorye/gists{/gist_id}","starred_url":"https://api.github.com/users/naorye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naorye/subscriptions","organizations_url":"https://api.github.com/users/naorye/orgs","repos_url":"https://api.github.com/users/naorye/repos","events_url":"https://api.github.com/users/naorye/events{/privacy}","received_events_url":"https://api.github.com/users/naorye/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-12-26T16:41:07Z","updated_at":"2018-08-01T23:40:18Z","closed_at":null,"author_association":"NONE","body":"I have the following logic:\r\n```\r\nexport const updateSomething = createLogic({\r\n    type: actions.updateSomething,\r\n\r\n    async process({ getState, action }, dispatch, done) {\r\n   \r\n        const { data } = await axios.post('url');\r\n\r\n        done(data);\r\n    }\r\n});\r\n\r\nexport const doSomething = createLogic({\r\n    type: actions.doSomething,\r\n\r\n    async process({ getState, action }, dispatch, done) {\r\n        const data = await dispatch(actions.updateSomething(data));\r\n\r\n        await dispatch(actions.doAnotherThingUponCompleteOnlyInThisFlow());\r\n        done();\r\n    }\r\n});\r\n```\r\nHere I am trying to achieve two things:\r\n1. Get a result of an action (inside logic). This can be solved by reading the state AFTER the action is done, but I think `done(data)` should somehow return that data.\r\n2. Wait for dispatch to complete and then dispatch another action. The code I've written doesn't wait for 'updateSomething' to complete. Therefore 'doAnotherThingUponCompleteOnlyInThisFlow' happens before 'updateSomething' completes which is incorrect flow in my app.\r\n\r\nWhat am I doing wrong?\r\nIs there any way to fix it?\r\n\r\nThanks,\r\nNaorYe"},"comment":{"url":"https://api.github.com/repos/jeffbski/redux-logic/issues/comments/409759675","html_url":"https://github.com/jeffbski/redux-logic/issues/88#issuecomment-409759675","issue_url":"https://api.github.com/repos/jeffbski/redux-logic/issues/88","id":409759675,"node_id":"MDEyOklzc3VlQ29tbWVudDQwOTc1OTY3NQ==","user":{"login":"jeffbski","id":5689,"node_id":"MDQ6VXNlcjU2ODk=","avatar_url":"https://avatars3.githubusercontent.com/u/5689?v=4","gravatar_id":"","url":"https://api.github.com/users/jeffbski","html_url":"https://github.com/jeffbski","followers_url":"https://api.github.com/users/jeffbski/followers","following_url":"https://api.github.com/users/jeffbski/following{/other_user}","gists_url":"https://api.github.com/users/jeffbski/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffbski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffbski/subscriptions","organizations_url":"https://api.github.com/users/jeffbski/orgs","repos_url":"https://api.github.com/users/jeffbski/repos","events_url":"https://api.github.com/users/jeffbski/events{/privacy}","received_events_url":"https://api.github.com/users/jeffbski/received_events","type":"User","site_admin":false},"created_at":"2018-08-01T23:40:18Z","updated_at":"2018-08-01T23:40:18Z","author_association":"OWNER","body":"@naorye That's pretty ingenious. I was pondering some ways we might build that in to redux-logic, but haven't settled on a definitive approach yet. \r\n\r\nSeems like your solution will meet the need. Nice job."}}
{"actor":{"display_login":"jeffbski"}}