Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Transition): expose previousTransition #304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

buschtoens
Copy link

@buschtoens buschtoens commented Aug 24, 2020

image

Just like you can use .followRedirects() to follow redirections, it would be really useful to be able to walk the other direction to know where we've originally come from.

@stefanpenner
Copy link
Collaborator

stefanpenner commented Nov 6, 2020

@buschtoens whats the motivation?

@buschtoens
Copy link
Author

For the life of me, I cannot remember what I wanted this for. 😅

I think the issue was that a new transition started by a redirect has the route that initiated the redirect as from and there is no way to get back to the original from that started the whole transition chain.

I think another issue might have been: before leaving / entering a specific route the user is redirected to an interstitial route. On this route there should be a button to retry the original transition.

@rwjblue
Copy link
Collaborator

rwjblue commented Nov 6, 2020

I think the issue was that a new transition started by a redirect has the route that initiated the redirect as from and there is no way to get back to the original from that started the whole transition chain.

You can keep track of them with the router service fairly easily if that sort of thing is what you need, but it isn't obvious to me what the expected behavior here actually should be.


From the router service RFC's section on routeDidChange:

Redirection example:

  1. current route is A
  2. user initiates a transition to B
  3. routeWillChange fires from A to B.
  4. B redirects to C
  5. routeWillChange fires from A to C.
  6. routeDidChange fires from A to C.

From the router service RFCs section on transition.from:

I'm proposing we add from and to properties on transition whose values are RouteInfo instances representing the initial and final leafmost routes for this transition. Like all RouteInfos, these are read-only and internally immutable. They are not observable, because a transition instance is never changed after creation.


Reading through that, it is clear that you can use the router services routeWillChange (keeping an array of the transition objects that happen from the first routeWillChange and the final routeDidChange which would reset the array).

However, it is not clear to me what "initial" in the transition.from section means. In other words, is the current behavior (that makes .from the target at the time of the redirect) wrong?

@wagenet
Copy link
Collaborator

wagenet commented Feb 9, 2022

@buschtoens @rwjblue status?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants