I'd like to create a custom Route class in Ember CLI. I have the following example working in an older app written with globals:
App.AuthenticatedRoute = Ember.Route.Extend({
beforeModel: function() {
//Do some things
}
});
App.DashboardRoute = App.AuthenticatedRoute.Extend({});
I'm familiar enough with ES6 modules to know that the example would look something like this...
var AuthenticatedRoute = Ember.Route.Extend({
beforeModel: function() {
//
}
});
export default AuthenticatedRoute;
...but I'm curious about the following:
- Where would this live in the app structure?
- How do I access this subclass in other modules?
Update:
To clarify my question: I was looking for information about where a custom implementation like this should live as opposed to a regular child route living in the app/routes dir. Ember CLI docs call out the following:
To provide a custom implementation for generated routes (equivalent to App.Route when using globals), use app/routes/basic.js.
http://www.ember-cli.com/#module-directory-naming-structure
...but I was not able to find any examples of this in practice, and it seems like an incomplete convention. I ended up treating the custom implementation as a standard route (app/routes/authenticated.js) and importing as needed.