-
Notifications
You must be signed in to change notification settings - Fork 640
Conversation
Note that I'm fine releasing 1.0 as is later tonight unless we magically agree with this and it goes in. |
Re: This gets a 👍 from me. |
if(routing === initialState) { | ||
routing = firstRoute; | ||
} | ||
|
||
// Only trigger history update is this is a new change or the | ||
// location has changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny typo: "Only trigger history update is" should be "Only trigger history update if"
👍 from me too. Points 1 and 2 look good. Adding the |
👍 In my testing I found no problems, so I think we should try to get this into 1.0 :) |
Ok cool! I'll go ahead and merge this. We can always make new releases if we find new problems. FWIW, I tried an approach that got rid of let avoidRouterUpdate = false;
history.listen(location => {
// ...
avoidRouterUpdate = true;
store.dispatch(pushPath(path, state));
});
store.subscribe(() => {
// ...
if(lastRoute !== getRouterState() && !avoidRouterUpdate) {
history.pushState(...);
}
}); I realized that we can just check the router state instances to see if they have changed. I got really close, but unfortunately could not get one last test to pass. This exercise made me really like |
I'll merge this now and update the docs. Feel free to open new PRs if anything breaks or there are any other improvements you find. |
Refactor initialization logic
Here's my take on how we should solve some of our initialization issues:
initialState
to the current location on the firsthistory.listen
call (which is called immediately) (fixes devtools "revert")lastRoute
as the flag to detect if it's the firsthistory.listen
call and also set it too (avoids making the store subscriber do anotherpushState
, previouslylastRoute === undefined
was making it do that). (fixes code ike Don't navigate immediately on boot. #81)INIT_ACTION
so that people can still listen toUPDATE_ACTION
just for changes. This is probably the most controversial. What should we do? Is it nice forUPDATE_ACTION
to run through the reducers on page load or not? I would think it would not be.