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

suggestion: use immer in updateSnapshot #11377

Closed

Conversation

phryneas
Copy link
Member

This would be an alternative suggestion to setSnapshot

Checklist:

  • If this PR contains changes to the library itself (not necessary for e.g. docs updates), please include a changeset (see CONTRIBUTING.md)
  • If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests

Copy link

changeset-bot bot commented Nov 21, 2023

⚠️ No Changeset found

Latest commit: 5d89467

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@phryneas phryneas requested a review from jerelmiller November 21, 2023 10:24
Comment on lines +437 to +439
ProfiledApp.updateSnapshot((snapshot) => {
snapshot.suspenseCount++;
});
Copy link
Member Author

@phryneas phryneas Nov 21, 2023

Choose a reason for hiding this comment

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

The fact that this is safely updatable is highlighted through the types here:
image

}
};

const setSnapshot: SetSnapshot<Snapshot> = (partialSnapshot) => {
Copy link
Member

@jerelmiller jerelmiller Nov 21, 2023

Choose a reason for hiding this comment

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

See #11376 (comment)

tl;dr; I'd still like to retain some way of doing a partial update without the need for a callback function to reduce noise for these kinds of updates. Immer may still make sense for this snapshot stuff, so I'm not opposed to introducing it. I just don't want to fully remove this partial update functionality.

Perhaps a different name for this function makes sense?

@jerelmiller
Copy link
Member

Discussed in Discord. We're going to avoid this dependency for now and instead rename the functions to replaceSnapshot and mergeSnapshot to better differentiate the behaviors. I will do this over in #11376

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants