weird infinite loop issue
If I set page({ hashbang: true }); before setting up my routes, the router gets stuck constantly refreshing the same page.
ex:
// Broken
page({ hashbang: true });
page('/', home);
page('/portfolio', portfolio);
page('/contact', contact);
// Works
page('/', home);
page('/portfolio', portfolio);
page('/contact', contact);
page({ hashbang: true });
It seems like the router should be tolerant of setting configuration before defining the routes, unless there's a specific reason why you wouldn't want to do this?
Adding Page.js to a site I'm working on and ran into the same thing. @robdodson Thanks for the examples for // Broken and // Works. Especially the latter. :-)
Ditto; this was causing me so much trouble today switching from "more-routing" to "page.js". I feel like setting up the "page( config )" stuff should happen first, and I never would have tried to set it at the end.
page(options) is the same as page.start(options). So while you think are configuring page you really are starting it, in which case not having routes defined is a problem.
For 2.0 (or perhaps before) I'm thinking about adding a page.configure(options) so you can more explicitly say (I want to configure page.js now) and it doesn't matter if you have routes defined or not.
So yeah, confusion is caused because configuring and starting page are overloaded into the same method(s).