ezekielchentnik / redux-history

connect history to redux
MIT License
5 stars 0 forks source link

Similarity with react-router-redux #1

Closed webmasterkai closed 8 years ago

webmasterkai commented 8 years ago

Have you taken a look at rackt/react-router-redux? It's similar to what you have here. https://github.com/rackt/react-router-redux/blob/master/src/index.js

Just wondering what you might have here that isn't there.

Thanks!

ezekielchentnik commented 8 years ago

check out my comments on

https://github.com/rackt/react-router-redux/pull/259#issuecomment-181234400

The difference is in intention/sentiments. I see history as more state that should should exist/sync into redux store; e.g. it should be available and act independently of react-router... although, probably will be used together.

I would love to hear your opinion and also looking for contribution; as well as sanity checks :)

cheers

ezekielchentnik commented 8 years ago

@webmasterkai my initial interest in redux-simple-router (the original react-router-redux) was it's simplicity. I have several projects where I do not need complex routing, nested routing, etc. (stuff react-router offers). react-router is awesome, but may be over complex depending on needs/project. if we evolve history for redux, I believe is more powerful than gluing to react.

webmasterkai commented 8 years ago

Thanks for your comment on 259! I agree wholeheartedly.

I've used react-router since it began but I now realize a URL is a serialized state slice (at best), more than it is a "route". I'd like for a URL to have the ability to completely restore the state of an application, not just a slice of it. Something like example.com/puppies-adorably-confused-by-rainbow/#xsu7 tells the user what's on the page and tells the app to fetch the state value associated with the xsu7 hash and restore its contents/position. In the beginning the only "state" on a webpage was its scroll position. The hash enabled navigating to specific location on the page. I see the hash as an opportunity to do to app state what bit.ly did to urls. That's a tangent for another day.

I tried so hard to like react-router-redux but the library’s primary goal is supporting React Router workflows rather than vanilla history so I decided to part ways.

Initially I thought it best to integrate with the history module but came to realize that I don't really need or want it. I don't want to observe history as much as I want to control it. The history module offers me little over window.history.

I started hacking away at a different solution: https://github.com/cape-io/redux-history-sync

Basically, I wanted navigating to a new "page" to act like it. I want UI state to reset/restore as I navigate to a new page or click back/forward. I usually don't want the filters I enabled on one page to carry over to another page. Clicking the browsers back/forward buttons while in the app is actually RESTORE_HISTORY not CREATE_HISTORY. Also, I feel like if the app is going to change the url shown in the address bar it should probably be a new history entry both in the browsers history (via history.pushState) and in Redux.

I also want browser history represented in redux. Basically Redux should keep track of the "pages" visited and what the state at each of those pages is. I want the app to understand where the user is, and where they have been. I want to be able to render a list of all the "pages" a user has visited from the Redux store. I want clicking on one of those pages to navigate to that page the same way selecting it from the browsers history dropdown would. If I click "reset" in Redux DevTools I want it to send my browser back to where I started. DevTools is about time travel after all. If I have navigated around to 6 pages and click "Reset" I want it to be the same as clicking my back button 6 times. After clicking "reset" proceeding to click the browsers back button should exit the app to whatever page I was on previously.

Have you looked at https://github.com/callum/redux-routing by chance?

I haven't had my morning coffee so I don't know if this is coherent. Hopefully a little...