page.js
page.js copied to clipboard
Document page.replace
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.
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.
I know it's a year on. This works for me :
page.replace(url, ctx.state, null, false);
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.