router.js icon indicating copy to clipboard operation
router.js copied to clipboard

feat(Transition): expose `previousTransition`

Open buschtoens opened this issue 5 years ago • 4 comments

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.

buschtoens avatar Aug 24 '20 15:08 buschtoens

@buschtoens whats the motivation?

stefanpenner avatar Nov 06 '20 00:11 stefanpenner

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.

buschtoens avatar Nov 06 '20 07:11 buschtoens

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?

rwjblue avatar Nov 06 '20 14:11 rwjblue

@buschtoens @rwjblue status?

wagenet avatar Feb 09 '22 15:02 wagenet