emberjs/ember.js — pull request #4233 by ef4 (2014-01-25 18:32:15+00:00)
Title: Adding some helpful methods for testing transitions

I've noticed several questions from others about how to use `willTransition` correctly, and in my own app I've had to write some fairly non-obvious code for inspecting `transition` objects within `willTransition` handlers. While documenting the `transition` object would help a bit, I think it would be preferable to define a higher-level API instead.

The kind of questions we'd want the user to easily answer would be:

* Does this transition leave the current route in place? At present the best way I know to check this is:

var me = this.routeName;
if (transition.handlerInfos.find(function(hi){ return hi.name == me;})){
// Really leaving
}

This often comes up when you transitioning into a deeper child route while leaving the current route alone.

* If the current route will still be part of the destination, does its context change?

var have = this.serialize(this.currentModel);
if (Ember.keys(have).every(function(param) {
return have[param] === transition.params[param];
})) {
console.log("identical context, skipping willTransition");
}

This PR is a sketch of one possible API that would provide these features. It's not a complete solution yet, and it doesn't consider `queryParams`. But I wanted to get some feedback first.

Do people like this API? If yes, does this need to go behind a feature flag?