page.js icon indicating copy to clipboard operation
page.js copied to clipboard

Document page.replace

Open rr- opened this issue 9 years ago • 4 comments
trafficstars

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.

rr- avatar Apr 13 '16 18:04 rr-

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.

pgraham avatar Apr 20 '16 01:04 pgraham

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

roboriaan avatar Jun 07 '17 13:06 roboriaan

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.

matthewp avatar Jan 19 '18 13:01 matthewp