willLeave and willChangeContext events #89
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This supercedes emberjs/ember.js#4233
My intention is to expose a public API that's more fine-grained than
willTransition
. The problem withwillTransition
is that it fires on your route regardless of whether your route is actually going to be affected by the transition. The user is left crawling through private state on the transition object to figure out whether their route is really going away or changing context.This change creates two new events:
willLeave
andwillChangeContext
.willLeave
fires on routes that will no longer be active after the transition.willChangeContext
fires on routes that will still be active but will re-resolve their models. Both of these hooks act likewillTransition
in the sense that they give you an opportunity to abort the transition before it happens. Common use cases include animating things away or prompting to user to deal with unsaved changes.If this PR is merged, I'll make a (documentation-only) PR against ember itself. As far as I can tell, no code changes will be necessary there.
I left
willTransition
alone, so this should be backward compatible with stable Ember APIs.