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

feat: apply Object.freeze in patchState on state in dev mode #4526

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rainerhahnekamp
Copy link
Contributor

Alternative version to protected the state from mutable changes via Object.freeze.

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Mutable changes in patchState don't trigger any kind of warning

Closes #4030

What is the new behavior?

In development mode (ngDevMode), Object.freeze is applied to the state, causing a runtime error on a mutable change.

Does this PR introduce a breaking change?

[x] Yes
[ ] No

Other information

  • I might be better to reuse the existing freeze function from the global store. For that, we would have to move freeze to @ngrx/operators. Maybe a follow-up PR or should I include it in the current one?

Copy link

netlify bot commented Sep 18, 2024

Deploy Preview for ngrx-io canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 4216e54
🔍 Latest deploy log https://app.netlify.com/sites/ngrx-io/deploys/66eadaa348f0b10008f6e09c

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.

@ngrx/signals: Improve Developer Experience for Immutability
1 participant