{"action":"created","issue":{"url":"https://api.github.com/repos/dvajs/dva/issues/863","repository_url":"https://api.github.com/repos/dvajs/dva","labels_url":"https://api.github.com/repos/dvajs/dva/issues/863/labels{/name}","comments_url":"https://api.github.com/repos/dvajs/dva/issues/863/comments","events_url":"https://api.github.com/repos/dvajs/dva/issues/863/events","html_url":"https://github.com/dvajs/dva/issues/863","id":224413660,"number":863,"title":"setup中如何获取 全局的state?","user":{"login":"linginging","id":8087475,"avatar_url":"https://avatars3.githubusercontent.com/u/8087475?v=3","gravatar_id":"","url":"https://api.github.com/users/linginging","html_url":"https://github.com/linginging","followers_url":"https://api.github.com/users/linginging/followers","following_url":"https://api.github.com/users/linginging/following{/other_user}","gists_url":"https://api.github.com/users/linginging/gists{/gist_id}","starred_url":"https://api.github.com/users/linginging/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linginging/subscriptions","organizations_url":"https://api.github.com/users/linginging/orgs","repos_url":"https://api.github.com/users/linginging/repos","events_url":"https://api.github.com/users/linginging/events{/privacy}","received_events_url":"https://api.github.com/users/linginging/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-04-26T10:07:29Z","updated_at":"2017-04-28T03:31:57Z","closed_at":null,"body":"  subscriptions: {\r\n    setup({ dispatch, history }) {\r\n      history.listen(location => {});\r\n   });\r\n}\r\n\r\nsetup中如何获取 全局的state?"},"comment":{"url":"https://api.github.com/repos/dvajs/dva/issues/comments/297898337","html_url":"https://github.com/dvajs/dva/issues/863#issuecomment-297898337","issue_url":"https://api.github.com/repos/dvajs/dva/issues/863","id":297898337,"user":{"login":"dicklwm","id":19289258,"avatar_url":"https://avatars0.githubusercontent.com/u/19289258?v=3","gravatar_id":"","url":"https://api.github.com/users/dicklwm","html_url":"https://github.com/dicklwm","followers_url":"https://api.github.com/users/dicklwm/followers","following_url":"https://api.github.com/users/dicklwm/following{/other_user}","gists_url":"https://api.github.com/users/dicklwm/gists{/gist_id}","starred_url":"https://api.github.com/users/dicklwm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dicklwm/subscriptions","organizations_url":"https://api.github.com/users/dicklwm/orgs","repos_url":"https://api.github.com/users/dicklwm/repos","events_url":"https://api.github.com/users/dicklwm/events{/privacy}","received_events_url":"https://api.github.com/users/dicklwm/received_events","type":"User","site_admin":false},"created_at":"2017-04-28T03:31:57Z","updated_at":"2017-04-28T03:31:57Z","body":"```js\r\n  effects: {\r\n    *getOwnerTasks({}, { call, put, select }){\r\n      const user = yield select(state => state.app.user);\r\n      const query = yield select(state => state.Home.query);\r\n      const payload = {\r\n        userId: user.userId,\r\n        name: query.name,\r\n        orderBy: query.orderBy,\r\n      }\r\n      const res = yield call(WorkflowService.API_GetOwnerTasks, payload);\r\n      if (res.data.success) {\r\n        yield put({\r\n          type: 'getOwnerTasksReducer',\r\n          payload: res.data.data,\r\n        })\r\n      }\r\n    },\r\n  },\r\n  subscriptions: {\r\n    setup({ dispatch, history }){\r\n      history.listen(({ pathname }) => {\r\n        if (pathname==='/home' || pathname==='/') {\r\n          if (window.sessionStorage.login===\"true\") {\r\n            dispatch({ type: 'getOwnerTasks' });\r\n          }\r\n        }\r\n      })\r\n    }\r\n  },\r\n```\r\n\r\n给你个参考，我是这样写的"}}
{"actor":{"display_login":"dicklwm"}}