mobx-router icon indicating copy to clipboard operation
mobx-router copied to clipboard

History Manipulation

Open eugenkiss opened this issue 7 years ago • 2 comments

Great work on this project! I've created a similar project (https://github.com/eugenkiss/static-mobx-routing) and I'm comparing the different approaches we took to see if there are things to improve.

Consider the following use case. You are on the homepage (/). You enter the route /new-post and create a new post. This leads you to route /post/12. When you now press the browser's back button you go back directly to / instead of /new-post. The reason I find this intuitive is that the new post became the post with the id 12 and therefore it makes sense to replace the history entry /new-post after successfully having created a post. You can see this working in my demo project: http://static-mobx-routing.surge.sh/

How would you suggest implementing this use case with mobx-router?

eugenkiss avatar Jan 22 '17 09:01 eugenkiss

Hey man! Your router looks amazing! I would looove if we can brainstorm on this because I needed it in few of my projects. Ping me on twitter @thekitze and let me know when can we chat.

kitze avatar Mar 15 '17 21:03 kitze

Will do! For general information purposes, here's the rough idea: Routes are part of a list (the history) that is (de)serializable and there is a pointer/index that points to the current route in the history. This pointer moves according to the user's history manipulation (e.g. pressing the back button decreases the by 1). You can manipulate this list however you please.

eugenkiss avatar Mar 16 '17 08:03 eugenkiss