7

I came across this in the wiki:

It is recommended that you divide your controller objects into smaller pieces of related functionality and have multiple routers / controllers, instead of just one giant router and controller.

I didn't understand how to apply this. Are there any examples or tutorials?

Right now, I'm playing with Marionette and using require.js. How would I go about implementing multiple routers and controllers?

Swadq
  • 1,837
  • 2
  • 15
  • 25
chapani
  • 420
  • 4
  • 14
  • It's a good thing to keep a good separation of concern. Maybe [this post](http://stackoverflow.com/questions/11056703/backbone-marionette-marionette-application-causing-require-js-module-load-error) can help you with marionette using require.js – marcoo Dec 11 '12 at 07:40
  • 1
    Thanks @marcoo. I understand that. My problem was how to _apply_ them in practice. Marionettejs Github wiki pages - [AppRouter](https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.approuter.md) and [Controller](https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.controller.md) gave me some understanding. – chapani Dec 15 '12 at 22:57

1 Answers1

5

I ended up with this in my "main.js":

MyApp.start();

new BlogRouter({
    controller: new BlogController()
});

new NewsRouter({
    controller: new NewsController()
});

Backbone.history.start();

I'm not sure if it's the right approach. But it's working. Hope it will help some newbies like me.

chapani
  • 420
  • 4
  • 14