Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Route lifecycle hooks guide from Ember meetup lightning talk
App.LibraryRoute = App.ApplicationRoute.extend({
activate: function () {
//no longer enter
this._super();
only called once on entering a route.
},
beforeModel: function () {
// any state you want in place before the model is initialized, this is called before any model promises are resolved
// also could be used to conditionally prevent access to a route by throwing transition.abort
},
model: function () {
// interesting note, if you tranisition into a route via a dynamic route segment this will never
// not get called because the model will have already been specified ie {{#link-to 'article' article}}
// in that case use beforeModel or afterModel
},
afterModel: function () {
//anything that may need to reference a model
},
serialize: function () {
// setup any dynamic routes
},
setupController: function () {
// set additional properties on the controller, or override it’s content.
},
renderTemplate: function () {
// can be useful for setting up third party libraries. with a call to this._super
//also could be used to setup a non-default template without super
},
deactivate: function () {
this._super();
//no longer exit
}
actions: {
willTransition: function () {
//can be used to prevent a transition on make sure some state is ready for the next route
},
}
});
@cbliard

This comment has been minimized.

Copy link

cbliard commented Sep 7, 2016

There is also the didTransition action which is fired after a transition to the route has successfully been completed.

@pixelpax

This comment has been minimized.

Copy link

pixelpax commented Sep 5, 2017

http://yoember.com/#lesson-6 has a good description of the hooks as well for anyone looking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.