{"action":"created","issue":{"url":"https://api.github.com/repos/yelouafi/redux-saga/issues/50","labels_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/50/labels{/name}","comments_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/50/comments","events_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/50/events","html_url":"https://github.com/yelouafi/redux-saga/issues/50","id":128249583,"number":50,"title":"Fork is only sort of non-blocking","user":{"login":"tgriesser","id":154748,"avatar_url":"https://avatars.githubusercontent.com/u/154748?v=3","gravatar_id":"","url":"https://api.github.com/users/tgriesser","html_url":"https://github.com/tgriesser","followers_url":"https://api.github.com/users/tgriesser/followers","following_url":"https://api.github.com/users/tgriesser/following{/other_user}","gists_url":"https://api.github.com/users/tgriesser/gists{/gist_id}","starred_url":"https://api.github.com/users/tgriesser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgriesser/subscriptions","organizations_url":"https://api.github.com/users/tgriesser/orgs","repos_url":"https://api.github.com/users/tgriesser/repos","events_url":"https://api.github.com/users/tgriesser/events{/privacy}","received_events_url":"https://api.github.com/users/tgriesser/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-22T21:26:46Z","updated_at":"2016-01-24T21:33:15Z","closed_at":null,"body":"Consider this example:\r\n\r\n```js\r\nfunction* fnA() {\r\n  while(true) {\r\n    let {payload} = yield take('a')\r\n    yield fork(someAction, payload)\r\n  }\r\n}\r\n\r\nfunction* fnB() {\r\n  yield put({type: 'a', payload: 1})\r\n  yield put({type: 'a', payload: 2})\r\n  yield put({type: 'a', payload: 3})\r\n}\r\n\r\nfunction* someAction(payload) {\r\n  console.log(payload)\r\n}\r\n\r\nexport default function* root() {\r\n  yield [\r\n    fork(fnA),\r\n    fork(fnB)\r\n  ]\r\n}\r\n```\r\n\r\nThe output I was expecting was `1, 2, 3`, however the actual output is `1, 3` this is because the `yield fork` doesn't continue on the while loop until a subsequent tick. This can be fixed by changing `fnA` to:\r\n\r\n```js\r\nfunction* fnA() {\r\n  let forked = false\r\n  while (!forked) {\r\n    let {payload} = yield take('a')\r\n    forked = yield fork(fnA)\r\n    yield fork(someAction, payload)\r\n  }\r\n}\r\n```\r\n\r\nHowever this makes logging turn into a pyramid and feels like the wrong approach. Am I thinking about this incorrectly or could we somehow force the next tick after a fork call?"},"comment":{"url":"https://api.github.com/repos/yelouafi/redux-saga/issues/comments/174343500","html_url":"https://github.com/yelouafi/redux-saga/issues/50#issuecomment-174343500","issue_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/50","id":174343500,"user":{"login":"emirotin","id":525832,"avatar_url":"https://avatars.githubusercontent.com/u/525832?v=3","gravatar_id":"","url":"https://api.github.com/users/emirotin","html_url":"https://github.com/emirotin","followers_url":"https://api.github.com/users/emirotin/followers","following_url":"https://api.github.com/users/emirotin/following{/other_user}","gists_url":"https://api.github.com/users/emirotin/gists{/gist_id}","starred_url":"https://api.github.com/users/emirotin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emirotin/subscriptions","organizations_url":"https://api.github.com/users/emirotin/orgs","repos_url":"https://api.github.com/users/emirotin/repos","events_url":"https://api.github.com/users/emirotin/events{/privacy}","received_events_url":"https://api.github.com/users/emirotin/received_events","type":"User","site_admin":false},"created_at":"2016-01-24T21:33:15Z","updated_at":"2016-01-24T21:33:15Z","body":"It seems to be related for my problem though I'm not sure how to fix it.\r\n\r\nI have the following XHR API saga: http://pastebin.com/rpkiZzXv\r\nIt receives an XHR request config and issue the request, communicating the result to the reducer by dispatching different actions.\r\n\r\nNow I have an app with 2 pages (index and content). Both of them have the same sidebar, and the second page (content) also has a component in the page body. Both the sidebar and the component dispatch the API call actions. \r\n\r\nIf I first go to index I see the sidebar API request dispatched, taken by the saga and executed. Then if I navigate to the content page I see the 2nd request properly dispatched and executed.\r\n\r\nBut if I directly visit the 2nd page, so that the 2 actions are dispatched almost simultaneously, the 2nd action is not taken by the saga. I see both actions properly dispatched through the redux chrome extension, but the 2nd one doesn't reach the saga code. Any hints?\r\n\r\n"}}