-
Notifications
You must be signed in to change notification settings - Fork 26
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
Should we allow setState() separate from update()? #57
Comments
There's always the possibility of But otherwise, yeah I would say keeping everything going through
I think currentchange is a simpler API. I think if your page isn't a SPA, this is probably the right API for you to consume history changes (which would mostly be fragment, link clicks, etc.). But I do agree that it's unlikely for a page to split a lot of their logic between the two events.
I think it should mean both. Ideally currentchange could replace things like popstate and hashchange wholesale, so I think it should be a superset of those events. I'm neutral on |
Combined with today's offline discussion about the difficulties of maintaining state across multiple processes (especially for non-current entries), I think we should get rid of setState(). I'll work on this change soon. |
Continuing from @tbondwilkinson's comment at #54 (comment):
I'm sympathetic to these concerns. I think the crucial question is whether we consider a no-URL-update change to the state to be a navigation, or not.
In particular, the discussions in #42 (comment) indicated to me that maybe state-but-not-URL updates are conceptually different. E.g., they would be used for syncing state from the DOM to the
state
object, and it'd be strange for them to be considered navigations. The design in the explainer after #54 makes it so thatupdate()
always causes a full navigation by default, which the app would intercept withnavigate
. It then expects you to usesetState()
for other cases.I may have jumped the gun here though in assuming they are different. If we think that an app will generally want to treat no-URL-update state changes as navigations on the same level as URL-update ones, then we should get rid of
setState()
and force everything throughupdate()
.A late-breaking addition to #54 was the
statechange
event, so you get that. And to be clear, you don't getcurrentchange
as formulated. Whethercurrentchange
fires or not is tied to a few questions:currentchange
, sincenavigate
is so powerful and per-entry events cover other cases. See Expanding examples and available information for currententrychange #14.currentchange
to mean "the current entry changed to a different entry than it was before" or "something about the current entry changed"? This is very related to Update vs. replace, entry mutability, and keys #7.The text was updated successfully, but these errors were encountered: