{"action":"created","issue":{"url":"https://api.github.com/repos/rackt/history/issues/22","labels_url":"https://api.github.com/repos/rackt/history/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/rackt/history/issues/22/comments","events_url":"https://api.github.com/repos/rackt/history/issues/22/events","html_url":"https://github.com/rackt/history/issues/22","id":100138219,"number":22,"title":"Transition Middleware","user":{"login":"aldendaniels","id":4658558,"avatar_url":"https://avatars.githubusercontent.com/u/4658558?v=3","gravatar_id":"","url":"https://api.github.com/users/aldendaniels","html_url":"https://github.com/aldendaniels","followers_url":"https://api.github.com/users/aldendaniels/followers","following_url":"https://api.github.com/users/aldendaniels/following{/other_user}","gists_url":"https://api.github.com/users/aldendaniels/gists{/gist_id}","starred_url":"https://api.github.com/users/aldendaniels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aldendaniels/subscriptions","organizations_url":"https://api.github.com/users/aldendaniels/orgs","repos_url":"https://api.github.com/users/aldendaniels/repos","events_url":"https://api.github.com/users/aldendaniels/events{/privacy}","received_events_url":"https://api.github.com/users/aldendaniels/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-08-10T18:40:29Z","updated_at":"2015-08-12T15:54:38Z","closed_at":null,"body":"I'd like to hook into history to do data loading. To do this, I need to be able to pause a transition while data loading is occurring. \r\n\r\nI think this can be simulated today using `registerTransitionHook()` and a custom `getUserConfirmation()` handler that doesn't actually show a user confirmation dialog. This is of course a hack.\r\n\r\nA better solution would look something like this:\r\n\r\n```javascript\r\nlet history = createBrowserHistory();\r\nhistory.registerTransitionMiddleware(function(nextLocation, prevLocation, fnNext, fnAbort) {\r\n   fetchSomeData(location).then(fnNext);\r\n});\r\n```\r\n\r\nThe transition would simply freeze until `fnNext` or `fnAbort` are called.\r\n\r\nIf the direction sounds good, then I could submit a PR for this."},"comment":{"url":"https://api.github.com/repos/rackt/history/issues/comments/130353070","html_url":"https://github.com/rackt/history/issues/22#issuecomment-130353070","issue_url":"https://api.github.com/repos/rackt/history/issues/22","id":130353070,"user":{"login":"mjackson","id":92839,"avatar_url":"https://avatars.githubusercontent.com/u/92839?v=3","gravatar_id":"","url":"https://api.github.com/users/mjackson","html_url":"https://github.com/mjackson","followers_url":"https://api.github.com/users/mjackson/followers","following_url":"https://api.github.com/users/mjackson/following{/other_user}","gists_url":"https://api.github.com/users/mjackson/gists{/gist_id}","starred_url":"https://api.github.com/users/mjackson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjackson/subscriptions","organizations_url":"https://api.github.com/users/mjackson/orgs","repos_url":"https://api.github.com/users/mjackson/repos","events_url":"https://api.github.com/users/mjackson/events{/privacy}","received_events_url":"https://api.github.com/users/mjackson/received_events","type":"User","site_admin":false},"created_at":"2015-08-12T15:54:38Z","updated_at":"2015-08-12T15:54:38Z","body":"> I think you can manage that scenario by redirecting push calls to replace if there is a pending transition.\r\n\r\nThere's probably still some work to be done in [the `transitionTo` function](https://github.com/rackt/history/blob/b81a64878bf25731517b341894098fe8b928fe9c/modules/createHistory.js#L92-L113) to support this, @taurose. Perhaps instead of throwing we should just change the `action` of the `nextLocation` to be a replace there..."}}