1
votes

I have some Ember code in a route where I am waiting on a transition object in order to act after the transition completes:

willTransition: function (transition) {
    ...

    // Wait until the transition has finished before continuing.
    transition.then(function () {
        // Transition successful
        ...
    }, function () {
        // Transition aborted
        ...
    });
}

The "successful transition" function is called in all but one case in my app. This case is when the transition is to a route which performs a transitionTo in its redirect method. The call to transitionTo aborts the original transition - the one I'm waiting on in my code above - and replaces the active transition with a new one. The promise I'm waiting on is then rejected so my abort handler is called.

Is there any way I can get the new transition object and wait on that?

1

1 Answers

1
votes

As of Ember 1.2 (changelog here) the didTransition hook was added to the router (pull request).

didTransition will be called after the transition has occurred.

App.TestRoute = Ember.Route.extend({
  actions: {
    willTransition: function(transition) {
      ...
    },
    didTransition: function() {
      ...
    }
  }
});

JSBin example