Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

Exporting INIT_PATH constant #96

Closed
wants to merge 1 commit into from
Closed

Conversation

tonovotny
Copy link

So we can use this action type in reducers

So we can use this action type in reducers
@kimjoar
Copy link
Collaborator

kimjoar commented Dec 9, 2015

Do you have an example use case for this? When we added it we didn't intend for it to be used in reducers.

@tonovotny
Copy link
Author

I'm using it to modify state according to action.payload.path value. Maybe the action.payload is not intended to be used externally (?)

@kimjoar
Copy link
Collaborator

kimjoar commented Dec 9, 2015

You should use UPDATE_PATH for that. The INIT_PATH is only intended to be used internally to set up the internal state we need for Redux DevTools to work as expected.

@tonovotny
Copy link
Author

Yes, I do. The problem is getting the initial value and my idea was simply using INIT_PATH action. Of course I can get it elsewhere but it's not so nice then..

@kimjoar kimjoar mentioned this pull request Dec 9, 2015
@kimjoar
Copy link
Collaborator

kimjoar commented Dec 9, 2015

Good point, @tonovotny. Actually, looking at the code now I'm not entirely sure we need INIT_PATH at all anymore... I created #97, which removes it. Let's see what @jlongster says.

@jlongster
Copy link
Member

I'm at a work week right now and things are crazy busy :( I think I can find some time today to take a look though. No comments yet!

@kimjoar
Copy link
Collaborator

kimjoar commented Dec 9, 2015

@jlongster 👍 If you've got some time, focus on #93. That's the only thing left for a 1.0. The rest we can get into later versions.

@jlongster
Copy link
Member

I actually think it's fine to listen for INIT_PATH if you are wanting to set up some state that depends on the current URL. But I'm not sure. It may be best just to always emit UPDATE_PATH.

@kimjoar
Copy link
Collaborator

kimjoar commented Dec 10, 2015

I'm in favour of UPDATE_PATH. But it's a breaking change, so open for both solutions. It shouldn't be a problem to "imitate" INIT_PATH in a reducer (only do something the first time you receive an UPDATE_PATH), so I prefer the "smaller API surface".

@tonovotny
Copy link
Author

I like small API surface too but would prefer unambiguous solutions, so INIT_PATH. But I'm OK with always emiting UPDATE_PATH.

@hunterc hunterc mentioned this pull request Dec 10, 2015
@kimjoar
Copy link
Collaborator

kimjoar commented Dec 10, 2015

Any examples of use cases where init is important, instead of just listening for update?

@kimjoar
Copy link
Collaborator

kimjoar commented Dec 11, 2015

If we compare these two tests I find it natural for UPDATE_PATH to work the same way. When you history.listen you first get the current url, then you get updates from this url.

@kimjoar kimjoar mentioned this pull request Dec 14, 2015
@jlongster
Copy link
Member

Closing in favor of #97

@jlongster jlongster closed this Dec 18, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants