{"action":"created","issue":{"url":"https://api.github.com/repos/mobxjs/mobx-react/issues/156","repository_url":"https://api.github.com/repos/mobxjs/mobx-react","labels_url":"https://api.github.com/repos/mobxjs/mobx-react/issues/156/labels{/name}","comments_url":"https://api.github.com/repos/mobxjs/mobx-react/issues/156/comments","events_url":"https://api.github.com/repos/mobxjs/mobx-react/issues/156/events","html_url":"https://github.com/mobxjs/mobx-react/issues/156","id":188093711,"number":156,"title":"Several \"global\" stores and a local store. Proper way?","user":{"login":"nbrady-techempower","id":1304934,"avatar_url":"https://avatars.githubusercontent.com/u/1304934?v=3","gravatar_id":"","url":"https://api.github.com/users/nbrady-techempower","html_url":"https://github.com/nbrady-techempower","followers_url":"https://api.github.com/users/nbrady-techempower/followers","following_url":"https://api.github.com/users/nbrady-techempower/following{/other_user}","gists_url":"https://api.github.com/users/nbrady-techempower/gists{/gist_id}","starred_url":"https://api.github.com/users/nbrady-techempower/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbrady-techempower/subscriptions","organizations_url":"https://api.github.com/users/nbrady-techempower/orgs","repos_url":"https://api.github.com/users/nbrady-techempower/repos","events_url":"https://api.github.com/users/nbrady-techempower/events{/privacy}","received_events_url":"https://api.github.com/users/nbrady-techempower/received_events","type":"User","site_admin":false},"labels":[{"id":445621280,"url":"https://api.github.com/repos/mobxjs/mobx-react/labels/needs%20investigation","name":"needs investigation","color":"f26f8b","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-11-08T20:21:13Z","updated_at":"2016-11-10T16:18:04Z","closed_at":null,"body":"The current structure I have seems to be working correctly *most of the time* but I'm having issues that make me wonder if I'm structuring things properly. The project is using ES6/ES7 syntax.\r\n\r\nI have a few mobx global stores that I'm passing down through a provider. These are stores that a large chunk of my application needs to know about. Then I have \"local\" stores to manage the state of each component. However, in those local stores, I need access to the global stores that I'm injecting. So here's an example of what I'm doing.\r\n\r\n```javascript\r\nimport React from 'react';\r\nimport { observer } from 'mobx-react';\r\n\r\nimport HeaderBlockStore from './HeaderBlockStore';\r\n\r\n@observer(['AppStore','ViewsStore'])\r\nclass HeaderBlock extends React.Component {\r\n\r\n  constructor(props) {\r\n    super(props);\r\n  }\r\n\r\n  componentWillMount() {\r\n    this.store = new HeaderBlockStore(this.props);\r\n  }\r\n\r\n/** more code **/\r\n```\r\n\r\nSo I'm importing the local store and creating a new store once this `HeaderBlock` component is created. I'm passing in the props of this component to its store so I can access the global `AppStore` and `ViewsStore` from within the `HeaderBlockStore`.\r\n\r\nBasically, I have a layout that looks something like:\r\n```\r\n<Header>\r\n<View>\r\n```\r\n\r\nAnd each `<View>` can manipulate the `ViewsStore`. `HeaderBlockStore` actions require knowledge of `ViewsStore`. (Think links in the header changing their actions based on what view we're currently on.) \r\n\r\nHowever, it seems that when ViewsStore's observables change, the corresponding props don't always change. I'm curious about the proper way to manage this problem (handle global stores in a more localized store to manipulate actions) as I don't see a clear answer in any documentation."},"comment":{"url":"https://api.github.com/repos/mobxjs/mobx-react/issues/comments/259733689","html_url":"https://github.com/mobxjs/mobx-react/issues/156#issuecomment-259733689","issue_url":"https://api.github.com/repos/mobxjs/mobx-react/issues/156","id":259733689,"user":{"login":"mweststrate","id":1820292,"avatar_url":"https://avatars.githubusercontent.com/u/1820292?v=3","gravatar_id":"","url":"https://api.github.com/users/mweststrate","html_url":"https://github.com/mweststrate","followers_url":"https://api.github.com/users/mweststrate/followers","following_url":"https://api.github.com/users/mweststrate/following{/other_user}","gists_url":"https://api.github.com/users/mweststrate/gists{/gist_id}","starred_url":"https://api.github.com/users/mweststrate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mweststrate/subscriptions","organizations_url":"https://api.github.com/users/mweststrate/orgs","repos_url":"https://api.github.com/users/mweststrate/repos","events_url":"https://api.github.com/users/mweststrate/events{/privacy}","received_events_url":"https://api.github.com/users/mweststrate/received_events","type":"User","site_admin":false},"created_at":"2016-11-10T16:18:04Z","updated_at":"2016-11-10T16:18:04Z","body":"Ah and double check, are all components that render observables marked with `observer`? Besides that general setup seems fine"}}
{"actor":{"display_login":"mweststrate"}}