AmpersandJS / ampersand-router

Clientside router with fallbacks for browsers that don't support pushState. Mostly lifted from Backbone.js.
MIT License
70 stars 16 forks source link

Think about and document how to handle multiple routers. Specifically starting them. #7

Closed latentflip closed 9 years ago

latentflip commented 10 years ago

AmpersandRouter automatically requires and instantiates a single ampersand-history object. AmpersandHistory serves as a global router (per frame) to handle hashchange events or pushState, match the appropriate route, and trigger callbacks. You shouldn't ever have to create one of these yourself since ampersand-router already contains one.

When all of your Routers have been created, and all of the routes are set up properly, call router.history.start() on one of your routers to begin monitoring hashchange events, and dispatching routes. Subsequent calls to history.start() will throw an error, and router.history.started is a boolean value indicating whether it has already been called.

joeybaker commented 10 years ago

I've been thinking about this too. In the past, I've just used a global property to track the "started" state. I know globals are ugly, but the address bar is a global… there's kinda no way around this. I kinda like:

window._ampHistoryStarted = true
HenrikJoreteg commented 9 years ago

I'm going to close this issue as it is quite old and doesn't have a clear action point. Feel free to re-open with more clarification if you feel like we should do something about this.