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

[v5] Remove state.history #2882

Merged
merged 4 commits into from
Dec 23, 2021
Merged

[v5] Remove state.history #2882

merged 4 commits into from
Dec 23, 2021

Conversation

davidkpiano
Copy link
Member

This PR removes the history property from the State object, for these reasons:

  • state.history breaks immutability from states since every penultimate state.history is deleted to prevent memory leaks
  • state.history is not used for the statechart history mechanism (state.historyValue is, and that is staying)
  • Users can/should keep track of previous state(s) themselves

I'm still on the fence whether this should be completely removed or just renamed to state.previous (cc. @Andarist) - I'd like to get an idea of how useful accessing the previous state is from within the machine, which is the most compelling use-case to keep this feature.

Note: This does not remove the history mechanism from XState machines.

@changeset-bot
Copy link

changeset-bot bot commented Dec 20, 2021

🦋 Changeset detected

Latest commit: 0096d9f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
xstate Major
@xstate/graph Major
@xstate/immer Major
@xstate/inspect Major
@xstate/react Major
@xstate/svelte Major
@xstate/test Major
@xstate/vue Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ghost
Copy link

ghost commented Dec 20, 2021

CodeSee Review Map:

Review these changes using an interactive CodeSee Map

Review in an interactive map

View more CodeSee Maps

Legend

CodeSee Map Legend

"count": 1,
"currentWeight": 1,
"relativeWeight": 1,
"count": 2,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it's somewhat surprising that this has been affected anyhow by this PR. Do you know why that is?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disregard this, I want to rework @xstate/analytics (very old project) before releasing it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason this has been affected is because it was using state.history, but now we have to use something different (which I added).

@Andarist
Copy link
Member

Andarist commented Dec 21, 2021

I'm still on the fence whether this should be completely removed or just renamed to state.previous (cc. @Andarist)

Renaming would have the same downsides as the current solution. I think it's safe to remove this completely and to figure out a better solution in the future IF we find any compelling use cases to provide access to this.

@davidkpiano davidkpiano merged commit 606dc99 into next Dec 23, 2021
@davidkpiano davidkpiano deleted the v5/remove-state-history branch December 23, 2021 13:05
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.

2 participants