The router is the core of any Ember.js application and it can get big, fast.
Keeping your entire application’s router in one file is going to lead to madness. Thankfully it’s quite a simple problem to resolve.
Lets imagine an application with a number of discrete sections - a blog, a list of members and an area to browse uploaded files.
We have an init.js which sets up the application:
Looks pretty straightforward, but that’s without any outlet management, serializing/deserializing, action handlers etc…
Breaking this up is pretty simple.
Anywhere we say Ember.Route.extend we’re defining an anonymous class,
so in order to split up the router we can just give the class a name and move it to a file of its own.
Update: As Jo Liss points out,
you can specify the base route when you assemble the router as opposed to hard coding it in each section. I really like this, feels very similar to
how engines are mounted in Rails.