Make Transition#urlMethod public#180
Closed
bendemboski wants to merge 1 commit intoemberjs:masterfrom
Closed
Conversation
Document this property and make it public so route hooks can detect the type (URL method) of transition that is occurring.
Contributor
|
Fix for the root cause of wanting this at #197 |
Author
|
Awesome, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Document this property and make it public so route hooks can detect the type (URL method) of transition that is occurring.
#169 documented the Transition class and specified several methods and properties as public or private. This is a follow-up in which I am proposing that we document the
Transition#urlMethodproperty and make it public. The Transition#method method that updates it is already public, so it seems to make sense to make it public as well, so there is a public way of reading it as well as writing it.Background
This issue describes a problem where a route that performs a redirect needs to know whether the transition's target URL is already in the history or not so it knows whether to call
replaceWith()ortransitionTo()in order to keep the navigation history correct.The workaround described in the comments involves using the
Transition#sequenceproperty, which is currently private, only used for logging, and set based on an incrementing static class property that is not reset when the app resets (e.g. in unit tests). In short, a hack.Making
Transition#urlMethodpublic would provide a much cleaner workaround for the bug. Even ignoring that issue, it seems plausible that certain routes might want to make different decisions based on whether the transition they are handling is doing a replace, update, or not modifying the history.