Skip to content
This repository was archived by the owner on Aug 21, 2026. It is now read-only.
This repository was archived by the owner on Aug 21, 2026. It is now read-only.

Should event.destination be an AppHistoryEntry for "traverse" navigations #139

Closed

Description

@domenic

Spinning off from #97, re-summarizing based on the current state of things. Orthogonal to #138.

For "traverse" navigations, we currently have event.destination in the navigate event being a static snapshot saying where we're heading. But it could just as easily be the AppHistoryEntry we're heading to. The AppHistoryEntry API is a superset of the AppHistoryDestination API.

The differences (benefits?) would be:

  • If it's an AppHistoryEntry, it will be "live". If you hold on to it, its url and getState() can update, and its index might become -1 if it gets kicked out of the app history list.
  • If it's an AppHistoryEntry, you could attach event handlers for the per-entry events

The drawbacks would be:

  • It might be confusing that event.destination is live for traverse navigations but a static snapshot for push/replace/reload navigations.
  • The reload case is especially tricky. We can't use AppHistoryEntry for reload navigations because given appHistory.reload({ state: newState }), we need to have event.destination.getState() return the new state, not the old state of the AppHistoryEntry. So although you might expect to get a real AppHistoryEntry for reloads, since like a traverse they're going to somewhere that already exists, you wouldn't get one.

Overall, making this change doesn't seem that compelling to me, but I'd like to keep this tracking issue open to see if people have other ideas.

Activity

  1. added
    changeA proposed change to the API, not foundational, but deeper than the surface
    on Jul 28, 2021
  2. bathos commented on Jul 28, 2021

    @bathos

    As someone doing kill-then-resurrect navigate handling (cancel or reverse initial attempt, perform transition, finally “commit” the original nav if the transition succeeds), I appreciate the snapshot behavior. It allows keeping the original navigate event around for that last step, where we’re trying (typically) to recreate the original nav attempt to the extent possible. If it weren’t a snapshot, we’d have to make the snapshot manually. That’s not hard, but it’s not super obvious that you’d need to, I think; it seems like an avoidable booby trap?

    (I suspect there are cases beyond this specific pattern, too, where people are likely to be attracted to just keeping a navigation event around for “recreating” after something does or doesn’t happen — e.g. in “discard unsaved changes” flows.)

    Not a strong opinion — just some feedback about why I think the snapshot behavior provides a bit of harder-to-screw-it-up-by-accident safety (and sometimes also convenience).

  3. domenic commented on Nov 4, 2021

    @domenic
    CollaboratorAuthor

    Let's stick with the snapshot behavior!

  4. wycats commented on Jun 24, 2022

    @wycats

    The Ember framework team discussed the possibility of basing the next iteration of our router on the Navigation API in today's meeting, and we're overall extremely optimistic that it's the right direction.

    From our perspective, as long as the AppHistoryDestination API is a subset of the AppHistoryEntry API and contains at least key and id, we're happy. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    changeA proposed change to the API, not foundational, but deeper than the surfacefeedback wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions