visionmedia / page.js

Micro client-side router inspired by the Express router
http://visionmedia.github.com/page.js
7.68k stars 688 forks source link

Document page.replace #368

Open rr- opened 8 years ago

rr- commented 8 years ago

Page.js exposes page.replace function, which is a very helpful utility. Unfortunately, right now it's left undocumented - in my opinion it deserves more attention.

My use case is synchronizing infinite pager through URL. This has multiple benefits - not only the user can be landed at the same spot when they leave and click "back", it also makes every page bookmarkable. The alternative to page.replace would be to use simple redirection with page.show, but this would push new history item every time the page is loaded, which significantly pollutes browser's history.

pgraham commented 8 years ago

I agree. I've implemented a simple refresh function to re-run the current route without adding history using page.replace.

The function is simple enough only requiring a single parameter and does not require any prerequisite state to be set so it should be safe enough to publicize this function.

roboriaan commented 7 years ago

I know it's a year on. This works for me : page.replace(url, ctx.state, null, false);

matthewp commented 6 years ago

I think we want to take care of https://github.com/visionmedia/page.js/issues/369 first by fixing the API before documenting the weird one. So I'm marking this as semver major so it can happen in 2.0.