{"action":"created","issue":{"url":"https://api.github.com/repos/yelouafi/redux-saga/issues/568","repository_url":"https://api.github.com/repos/yelouafi/redux-saga","labels_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/568/labels{/name}","comments_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/568/comments","events_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/568/events","html_url":"https://github.com/yelouafi/redux-saga/issues/568","id":180979555,"number":568,"title":"Running sagas on react-router's onEnter hook","user":{"login":"luandro","id":693728,"avatar_url":"https://avatars.githubusercontent.com/u/693728?v=3","gravatar_id":"","url":"https://api.github.com/users/luandro","html_url":"https://github.com/luandro","followers_url":"https://api.github.com/users/luandro/followers","following_url":"https://api.github.com/users/luandro/following{/other_user}","gists_url":"https://api.github.com/users/luandro/gists{/gist_id}","starred_url":"https://api.github.com/users/luandro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luandro/subscriptions","organizations_url":"https://api.github.com/users/luandro/orgs","repos_url":"https://api.github.com/users/luandro/repos","events_url":"https://api.github.com/users/luandro/events{/privacy}","received_events_url":"https://api.github.com/users/luandro/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-04T19:14:40Z","updated_at":"2016-11-30T20:19:17Z","closed_at":"2016-11-30T20:19:17Z","body":"I've been trying to get sagas to run on react-router's `onEnter` hook: \n\n```\nconst loadData = (nextState, replace, cb) => {\n    const path = nextState.location.pathname;\n    const loader = new Promise((resolve) => {\n      switch (path) {\n        case '/news':\n          resolve(store.dispatch(loadNews()));\n        default:\n      }\n    });\n    loader.then(() => cb());\n  };\n```\n\n```\n     {\n          onEnter: (_, nextState, replace, cb) => loadData(_, nextState, replace, cb),\n          path: 'news',\n          getComponent(location, cb) {\n            System.import('containers/New')\n              .then(loadModule(cb))\n              .catch(errorLoading);\n          },\n        },\n```\n\nThe `loadNews` action get's dispatched, but the saga which is watching it doesn't get called\n\n```\nexport function* getNewsWatcher() {\n  while (yield take(GET_NEWS)) {\n    console.log('GET_NEWS saga got called');\n    yield call(postGetNews);\n  }\n}\n```\n\nIt works if I navigate from one route such as `/` to `/new`. But if I start running the app from the `/new` route, where the action is called, it doesn't.\n\nAny thoughts?\n"},"comment":{"url":"https://api.github.com/repos/yelouafi/redux-saga/issues/comments/263983605","html_url":"https://github.com/yelouafi/redux-saga/issues/568#issuecomment-263983605","issue_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/568","id":263983605,"user":{"login":"yelouafi","id":5453835,"avatar_url":"https://avatars.githubusercontent.com/u/5453835?v=3","gravatar_id":"","url":"https://api.github.com/users/yelouafi","html_url":"https://github.com/yelouafi","followers_url":"https://api.github.com/users/yelouafi/followers","following_url":"https://api.github.com/users/yelouafi/following{/other_user}","gists_url":"https://api.github.com/users/yelouafi/gists{/gist_id}","starred_url":"https://api.github.com/users/yelouafi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yelouafi/subscriptions","organizations_url":"https://api.github.com/users/yelouafi/orgs","repos_url":"https://api.github.com/users/yelouafi/repos","events_url":"https://api.github.com/users/yelouafi/events{/privacy}","received_events_url":"https://api.github.com/users/yelouafi/received_events","type":"User","site_admin":false},"created_at":"2016-11-30T20:19:17Z","updated_at":"2016-11-30T20:19:17Z","body":"closing this as it seems more related to react-router"}}
{"actor":{"display_login":"yelouafi"}}