-
Notifications
You must be signed in to change notification settings - Fork 644
Conversation
This is looking good. I really don't want to do a deep comparison on state though; luckily, I figured out they comparing locations is the wrong way to detect changes anyway. See the new sync logic at #40. I'm going to merge it after I write some basic tests. I need this to be rebased on top of that once I land that. Thanks a lot for this PR! Either go ahead and rebase or I'll ping you when it's merged. |
Also see #21 (comment). I'm not sure if we want to change actions names or not. |
Since this is already changing the API for Or for that matter, since |
I'm down with that. Let's go ahead and change the API to |
Matching the naming scheme used by history makes the most sense to me, but it sounds like they might be renaming things as well (to just |
Yeah, that's what Ryan said. Also I don't think |
I just landed the new sync logic. Can you rebase? |
And also add tests! |
@jlongster Great — I'll rebase and fix the tests asap |
I think this PR will reintroduce the problem with devtools where a 'RESET' action will change the path to '/' regardless of the initial URL. In my opinion the benefits of landing this outweigh this devtools regression, but it would be nice if we could figure out a way round it. |
This is the PR where it was originally "fixed" (modulo my typo of not quoting undefined) #6 |
@ellbee that's true, I didn't notice we lost that check. Should be easy to add back in the check to see if we have a Maybe what we should do is set |
Although I guess we'd have to keep track if we've set the initialState or not and not do it multiple times... I don't love it, but |
8beea7d
to
b7f10aa
Compare
@jlongster Rebased and added tests. I also fixed a bug with (I thought about cleaning up a couple of things in the tests, but I'll do that in a follow-up PR — this is already a big change) |
function locationToString(location) { | ||
return location.pathname + location.search + location.hash; | ||
function locationsAreEqual(a, b) { | ||
return a.path === b.path && deepEqual(a.state, b.state); |
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.
Are you sure we need to deepEqual
here? I'm having a hard time wrapping my head around this, but probably because I haven't use that state much.
Hm, I have a thought... read my 2nd comment below.
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.
It's basically a copy of https://github.com/rackt/history/blob/master/modules/createHistory.js#L12-L18
Thanks a bunch for this, it's awesome! I'll try to merge it soon, just wanted to look through it once more. It is thanksgiving also :) |
@jlongster Thanks for the comments — I'll take a look and try to get it fixed without the deep-equal :) |
What was the bug with |
@jlongster The bug: kimjoar@a0d6945 It's specified as Btw, pushed a test that would fail if we remove the |
Ok, thanks. That sounds like a good plan. |
Thanks all. I have to leave and it's Thanksgiving so I'm going to be slow to reply over the next day or two. I'm happy to merge this in with |
@jlongster Everything looks ok when testing in my app, so it should be ready to merge. Have a great Thanksgiving! |
I found a way to remove |
Cool! I think I'm going to wait until tomorrow night to merge. We got a lot of attention today and I just don't want to merge something big right before a day when I'm not going to be around, even though it's just the master branch. |
👍 Relax and enjoy Thanksgiving! Got some ideas to solve deep-equal, but I think we need tests running in browsers to ensure everything still works as expected. |
Alright let's just merge this now and clean it up over the next few days for a release. |
Handle routing state and replace
Thanks a lot for all the work @kjbekkelund and others! |
A couple of different changes here. Could split into multiple PRs, but wanted to see if you're interested first (I've also of course seen the PRs that already exist, but just copied this from the changes I needed for my app)
The changes:
window.location
, always rely on thelocation
we receive fromhistory
noRouterUpdate=true
location.state
(and therefore a deep equal check when comparing locations)history.createPath
instead oflocationToString
Also thought about renaming, but didn't for this PR:
updatePath
topushPath
(closer tohistory.push
andhistory.replace
)noRouterUpdate
toskipUpdate
ornoUpdate
syncReduxAndRouter
tosyncReduxAndHistory