{"action":"created","issue":{"url":"https://api.github.com/repos/BinaryMuse/fluxxor/issues/100","labels_url":"https://api.github.com/repos/BinaryMuse/fluxxor/issues/100/labels{/name}","comments_url":"https://api.github.com/repos/BinaryMuse/fluxxor/issues/100/comments","events_url":"https://api.github.com/repos/BinaryMuse/fluxxor/issues/100/events","html_url":"https://github.com/BinaryMuse/fluxxor/pull/100","id":56343825,"number":100,"title":"Allow injection of a dispatch wrapper","user":{"login":"BinaryMuse","id":189606,"avatar_url":"https://avatars.githubusercontent.com/u/189606?v=3","gravatar_id":"","url":"https://api.github.com/users/BinaryMuse","html_url":"https://github.com/BinaryMuse","followers_url":"https://api.github.com/users/BinaryMuse/followers","following_url":"https://api.github.com/users/BinaryMuse/following{/other_user}","gists_url":"https://api.github.com/users/BinaryMuse/gists{/gist_id}","starred_url":"https://api.github.com/users/BinaryMuse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BinaryMuse/subscriptions","organizations_url":"https://api.github.com/users/BinaryMuse/orgs","repos_url":"https://api.github.com/users/BinaryMuse/repos","events_url":"https://api.github.com/users/BinaryMuse/events{/privacy}","received_events_url":"https://api.github.com/users/BinaryMuse/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-03T07:33:14Z","updated_at":"2015-02-04T10:55:03Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/BinaryMuse/fluxxor/pulls/100","html_url":"https://github.com/BinaryMuse/fluxxor/pull/100","diff_url":"https://github.com/BinaryMuse/fluxxor/pull/100.diff","patch_url":"https://github.com/BinaryMuse/fluxxor/pull/100.patch"},"body":"React automatically batches updates when inside a synthetic event handler, but asynchronous updates do not get the same treatment. Consider the following scenario:\r\n\r\n1. A button in ComponentA calls an action creator\r\n2. The action creator calls an async API\r\n3. As a result of the async call, the action creator dispatches an action\r\n4. That action sets new state in a store\r\n5. The new store data causes a new child to be mounted inside ComponentA (let's call it ComponentB)\r\n6. ComponentB fires an action immediately, via componentDid/WillMount\r\n\r\nUnlike re-renders from synchronous action dispatches (which generally happen in the context of a synthetic event), asynchronous dispatches aren't called within the context of React's batching strategy. This means the dispatch loop is still in progress when ComponentB mounts, causing a cascading dispatch exception.\r\n\r\n`Flux#setDispatchWrapper` allows you to pass a function to wrap dispatches in; in most (all?) cases, you'll want to pass `React.addons.batchedUpdates` (or some custom function that calls it) in order to force all dispatches to happen in the context of React's batched updates.\r\n\r\nFixes #92"},"comment":{"url":"https://api.github.com/repos/BinaryMuse/fluxxor/issues/comments/72835677","html_url":"https://github.com/BinaryMuse/fluxxor/pull/100#issuecomment-72835677","issue_url":"https://api.github.com/repos/BinaryMuse/fluxxor/issues/100","id":72835677,"user":{"login":"nelix","id":33324,"avatar_url":"https://avatars.githubusercontent.com/u/33324?v=3","gravatar_id":"","url":"https://api.github.com/users/nelix","html_url":"https://github.com/nelix","followers_url":"https://api.github.com/users/nelix/followers","following_url":"https://api.github.com/users/nelix/following{/other_user}","gists_url":"https://api.github.com/users/nelix/gists{/gist_id}","starred_url":"https://api.github.com/users/nelix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nelix/subscriptions","organizations_url":"https://api.github.com/users/nelix/orgs","repos_url":"https://api.github.com/users/nelix/repos","events_url":"https://api.github.com/users/nelix/events{/privacy}","received_events_url":"https://api.github.com/users/nelix/received_events","type":"User","site_admin":false},"created_at":"2015-02-04T10:55:03Z","updated_at":"2015-02-04T10:55:03Z","body":"This is pretty useful, I was hoping to be able to use it to replay dispatches and to send them via postMessage (for example, when having stores in a sharedWorker). "}}