The API facelift his gone to great lengths to separate the phase in which routes and their validation/model promises are being resolved from the phase where routes are actually being fully entered with their resolved contexts. Beforehand, you had a mishmash of stuff being stored on Routes even though they weren’t fully entered, and a lot of the code suffered because of it.
That said, if you’re transitioning into /posts/123/comments/456
, the CommentsRoute
may very well need the resolved Post object from a parent route to do its thing. In the previous iteration of the API, you could look up the resolved post object in a parameter passed to each of the validation hooks called resolvedParentModels
, but that API was kinda crappy and that parameter has since been replaced with a transitionEvent
parameter. Instead of looking up this during-transition resolved parent model, I just made Route#modelFor
smart enough to try and look up any parent models on the current transitionEvent if we’re in mid-transition.
So, if CommentsRoute
needed the parent post, it can just do this.modelFor('post')
(which is how it always worked in the past).