{"action":"created","issue":{"url":"https://api.github.com/repos/yahoo/fluxible/issues/287","labels_url":"https://api.github.com/repos/yahoo/fluxible/issues/287/labels{/name}","comments_url":"https://api.github.com/repos/yahoo/fluxible/issues/287/comments","events_url":"https://api.github.com/repos/yahoo/fluxible/issues/287/events","html_url":"https://github.com/yahoo/fluxible/issues/287","id":112376678,"number":287,"title":"ConnectToStore called multiple time","user":{"login":"Wykks","id":1236069,"avatar_url":"https://avatars.githubusercontent.com/u/1236069?v=3","gravatar_id":"","url":"https://api.github.com/users/Wykks","html_url":"https://github.com/Wykks","followers_url":"https://api.github.com/users/Wykks/followers","following_url":"https://api.github.com/users/Wykks/following{/other_user}","gists_url":"https://api.github.com/users/Wykks/gists{/gist_id}","starred_url":"https://api.github.com/users/Wykks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wykks/subscriptions","organizations_url":"https://api.github.com/users/Wykks/orgs","repos_url":"https://api.github.com/users/Wykks/repos","events_url":"https://api.github.com/users/Wykks/events{/privacy}","received_events_url":"https://api.github.com/users/Wykks/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-10-20T14:06:42Z","updated_at":"2015-10-30T18:22:38Z","closed_at":null,"body":"Following the doc : http://fluxible.io/addons/connectToStores.html\r\nconnectToStores is listening to the stores for updates. It should only listen to the array of store passed in arguments, no ?\r\n\r\nUsing the generator-fluxible code base, when I do something like this : \r\n\r\n    @connectToStores([ArticlesStore], (context, props) => {\r\n        debug('ConnectToStore called');\r\n        const articleStore = context.getStore(ArticlesStore);\r\n        const slug = props.currentRoute.get('params').get('slug');\r\n        return {\r\n            article: articleStore.getSingleArticle(slug)\r\n        };\r\n    })\r\n\r\nconnectToStores is called 3 times : \r\nThe expected one : \r\n\r\n    Dispatchr:Action executing handler for ArticlesStore\r\n    ConnectToStore called\r\n\r\nAnd two others times afterwards : \r\n\r\n    Dispatchr:Action executing handler for RouteStore\r\n    ConnectToStore called\r\n    [...]\r\n    Dispatchr:Action executing handler for ApplicationStore\r\n    browser.js:112 Dispatchr:Action waiting on function StaticRouteStore() {\r\n            RouteStore.apply(this, arguments);\r\n        }\r\n    ConnectToStore called\r\n\r\nWhy RouteStore and ApplicationStore changes are firing this ConnectToStore ? Am I missing something here ?\r\n\r\nThanks ! :)\r\n"},"comment":{"url":"https://api.github.com/repos/yahoo/fluxible/issues/comments/152608463","html_url":"https://github.com/yahoo/fluxible/issues/287#issuecomment-152608463","issue_url":"https://api.github.com/repos/yahoo/fluxible/issues/287","id":152608463,"user":{"login":"mridgway","id":191142,"avatar_url":"https://avatars.githubusercontent.com/u/191142?v=3","gravatar_id":"","url":"https://api.github.com/users/mridgway","html_url":"https://github.com/mridgway","followers_url":"https://api.github.com/users/mridgway/followers","following_url":"https://api.github.com/users/mridgway/following{/other_user}","gists_url":"https://api.github.com/users/mridgway/gists{/gist_id}","starred_url":"https://api.github.com/users/mridgway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mridgway/subscriptions","organizations_url":"https://api.github.com/users/mridgway/orgs","repos_url":"https://api.github.com/users/mridgway/repos","events_url":"https://api.github.com/users/mridgway/events{/privacy}","received_events_url":"https://api.github.com/users/mridgway/received_events","type":"User","site_admin":false},"created_at":"2015-10-30T18:22:38Z","updated_at":"2015-10-30T18:22:38Z","body":"So it looks like this is the flow:\r\n\r\n1. `RouteStore.NAVIGATE_START` causes new component to render and calls `getInitialState`\r\n2. `ArticleStore. RECEIVE_ARTICLE_SUCCESS ` triggers change event\r\n3. `RouteStore.NAVIGATE_SUCCESS` triggers `componentWillReceiveProps`\r\n4. `ApplicationStore.NAVIGATE_SUCCESS` triggers a second `componentWillReceiveProps`\r\n\r\nSo it seems like `componentWillReceiveProps` causing state changes is the biggest culprit here. In theory, the state could be based on props which would require that we run this hook, but it could be optimized to not call `connectToStores` if the state is not based on any props. \r\n\r\nPerhaps we can provide an option to flag certain props as influential to state or a hook to return before calling `connectToStores` that takes in `props`: `shouldUpdateState(props)`."}}