-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
selectSignal() fires on every global state change #3882
Comments
The Angular framework |
Hey @mikezks, I'd like to see how Let me know if I'm missing something. EDIT: I reproduced it by changing @mikezks do you want to create a PR to fix this issue? It can be fixed by changing the selectSignal<K>(
selector: (state: T) => K,
options?: SelectSignalOptions<K>
): Signal<K> {
return computed(() => selector(this.state()), {
equal: options?.equal || ((previous, current) => previous === current),
});
} |
Thanks for checking that, @markostanimirovic. Yes, I will provide a PR for that. |
I noticed that my |
I assume this is not related. |
More context: |
So in a trivial app the behavior I observed does not occur. (The The app I noticed the issue on has some more complexities which I have not fully investigated in the reproduction though.
There are probably a lot of other things in the app I tested with that could impact this beyond even just these. I will let you know out if I find any specific situations that recreate the behavior. |
Great, thanks. If the regression is specific to the v16-next update or later v16-final, this is definitely important to know. |
Just tested in 16.0.0 and the issue I observed does not occur. 🎉 |
Which @ngrx/* package(s) are the source of the bug?
store
Minimal reproduction of the bug/regression with instructions
All selectors created with
selectSignal()
fire on every global state change, even if the related state received no update.Why does this happen?
The Angular team decided to emit a new Signal value for each object set, even if the reference stays the same.
This is an issue for working with immuable data (the default for NgRx state management).
The behavior can be fixes manually by configuring an equal function:
Necessary change
This equal compare behavior should be set automatically for
selectSignal()
as the current behavior is not expected by the developer that works with an immutable state pattern.Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)
NgRx: 16 RC.0
Angular 16.0.0
Other information
May affect
@ngrx/component-store
as well.Credits to @manfredsteyer who found this issue.
I would be willing to submit a PR to fix this issue
The text was updated successfully, but these errors were encountered: