tbranyen / backbone.routemanager

Better route management for Backbone.js projects.
MIT License
111 stars 10 forks source link

AMD and multiple routers? #1

Open MMRandy opened 11 years ago

MMRandy commented 11 years ago

Tim, this a cool piece of work, however...having an issue getting it up and running in our AMD+RequireJS BBB framework. I have some questions...but don't want to litter this Issues area with questions that are not "Issues" per se with the RouteManager. Where is the best place to explain my problem to you? Thanks, and thanks for your contributions to the community, great stuff!

Randy

MMRandy commented 11 years ago

Ok, well...guess I'll just run through the issue real quick.

In my scenario above (AMD), I do not have "nested" routers, but I do have many Backbone.Routers...one for each Module of my app. I am not a fan of creating one big monolithic router containing the routes of all Modules b/c it pretty much defeats the purpose of AMD. I want to decouple the Modules from each other and the main app...and load them on the fly as needed.

However, I cannot seem to get the routemanager to work correctly with the individual routers. If each Router extends the normal BB.Router object, they do not inherit any of the functionality form the RouteManager (most interested in routeFilters), so the filters obviously do not fire. If I make each one an extension of RouterMAnager, then triggering one route in a module will fire as many times as I have routes in that module. Not the desired behavior. I am using another routeFilter implementation that works fine and fires the before event only once per route call, but they lack your implementation of sync and async calls in the filters, which is awesome.

Any ideas of why your filter implementation would fire once per every route when using multiple routers?

Thanks

tbranyen commented 11 years ago

This is a good point. I'm rethinking how filters are going to work.