RFC for Hook/Event for Transitioning During a Transition#126
RFC for Hook/Event for Transitioning During a Transition#126nickiaconis wants to merge 3 commits intoemberjs:masterfrom
Conversation
|
|
Love it. Seems like an obvious win. |
text/0000-transition-hooks-events.md
Outdated
| willChangeTransition: hookForAllTransitions, | ||
| }); | ||
|
|
||
| Router.on('willTransition', callbackForAllTransitions); |
There was a problem hiding this comment.
There are a few examples in this RFC that suggest:
const Router = Ember.Router;
Router.on('stuff', function() {
alert('changing!');
});I think I get what you mean here, but I didn't think you could call .on on the Router class itself (I thought it only works in instances). Demo here: http://rwjblue.jsbin.com/koqofoc/edit?html,js
There was a problem hiding this comment.
Agreed. Also, willTransition and didTransition fire as actions:
http://jsbin.com/nemuzeteju/1/edit?html,js,output
It is proposed that an action be added for willChangeTransition? Is that possible to add, since the router is in transition (I'm not crazy familiar with the code)?
There was a problem hiding this comment.
Ya, so they fire as method calls and events on Ember.Router instances, and as actions on Ember.Route instances. We should do the same pattern here with the new ones.
There was a problem hiding this comment.
@rwjblue Good point about the instance/class mixup. Will fix.
On the method/event/action side, I'm a little confused. Are you saying willChangeTransition should exist for Routes as well as the Router? I'm of the opinion it should not.
There was a problem hiding this comment.
@nickiaconis - If the idea is to augment the existing willTransition / didTransition hooks then it stands to reason that the new hook should fire the same ways that the ones it is augmenting does. Since the existing hooks for willTransition and didTransition fire as both events and methods on the Ember.Router instance and fire as actions on Ember.Route instances I would have assumed that the new one would also.
I suppose that I don't care a ton that the new willChangeTransition follows that same pattern, but we should have a very specific reason for deviating.
|
I've added this to the agenda for next week's core meeting 😄 |
|
@nickiaconis we talked about this today. I believe there is some feedback from @wycats coming re: the name and the pedagogical section. I'll punt that to him. This RFC doesn't mention adding Thanks for your continued work on this, the whole team is enthusiastic about keeping you moving and landing the feature! |
|
@mixonic I do not believe this hook/event should be implemented for Routes. I believe it should only be implemented for the Router. Here's a look at the lifecycle of a transition to explain why:
Step 5, triggering |
|
I definitely appreciate the effort and write up here @nickiaconis. Thank you for being thorough and passionate. 😸 To your question:
The same route that I am very 👎 on adding a new event that seems similar to |
|
@nickiaconis during step #5 what is the active route? The transitioned-from route ( |
@rwjblue The use case you've described spans routes, as I believe all use cases of Concerns that span routes belong at the Router level. Implementing route-spanning concerns at the Route level increases the coupling between the involved routes. I think it is the framework's responsibility to not provide primitives that will lead developers into anti-patterns. |
Actions all bubble, it is extremely common to have a single
I absolutely agree! It is also the frameworks responsibility to be internally consistent. |
|
I don't feel particularly strongly about @nickiaconis Seems like the only open question is what the active route should be in your step five above? |
|
@nathanhammond Sounds to me like @rwjblue already answered that.
I'll update the RFC to include this at the Route level. |
e68bc7a to
1bd98ec
Compare
|
I'd just like to chime in that I would really like to have this hook available. I have a question about how this interacts with Also, how is the recursiveness handled when a new transition is triggered during the |
|
@kanongil Inside of the Router there is only ever one "active" transition. Any time that transition changes This proposal is not implemented with the DOM model where something like |
|
@nickiaconis - Can you review the recent updates to the Router Service RFC and see if the events proposed there will meet your needs? |
|
@rwjblue - It will be more difficult to distinguish between a normal transition and a redirect, but should still be doable. This was not a need I saw personally, but others may need it. Tracking is the first use case that comes to mind. The Router Service RFC's events' names are much better than |
Rendered.