-
-
Notifications
You must be signed in to change notification settings - Fork 2k
fix(signals): expose readonly signals in slices #4959
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
base: main
Are you sure you want to change the base?
fix(signals): expose readonly signals in slices #4959
Conversation
`withState`, `signalState`, and `withLinkedState` now pass a `Signal` instead of the original `WritableSignal` to the DeepSignal. This prevents accidental misuse where consumers (e.g. `ngModel` or other APIs with incompatible types) could assert `WritableSignal` and write directly into the state. Closes ngrx#4958
✅ Deploy Preview for ngrx-site-v19 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for ngrx-io canceled.
|
|
Let's merge this in v21 to prevent unintentional breaking changes. |
timdeschryver
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As Marko has mentioned this can be a breaking change.
Do we want to include it in the migration notes?
If so, we should flag this PR as breaking change to not forget about it.
|
@timdeschryver just added the label "breaking changes" as suggested |
|
@rainerhahnekamp @timdeschryver After revisiting this PR, I'm not sure if we should proceed with it, because maybe in the future we will introduce deep writable signals within the store while keeping them as read-only outside of the store instance. In that case, deep writables would be protected only at the TypeScript level, and we would have to revert this (and make another breaking change). Therefore, I'm not sure if this change is worth it. E.g., for the state source, we also have protection only at the TS level. If someone wants to avoid it (and use |
|
the thing was that it happened via two-way binding with @manfredsteyer you reported this one. Can you elaborate on it? |
|
@markostanimirovic, do you think changes like deep-writables - even if they are only inside the store - can be done without breaking changes? As you remember, even the multi-signals approach in v20 should have been internal-only, but it turned out to be the opposite. |
Yes, maybe there would be a breaking change for deep writables, but regardless, I'm wondering do we need to introduce this one. |
withState,signalState, andwithLinkedStatenow pass aSignalinstead of the originalWritableSignalto the DeepSignal.This prevents accidental misuse where consumers (e.g.
ngModelor other APIs with incompatible types) could assertWritableSignaland write directly into the state.Closes #4958
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Closes #4958
What is the new behavior?
Will throw an error if set is called because the Signal is readonly.
Does this PR introduce a breaking change?