-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Effect runs when there was no change at the end #56071
Comments
Effects have no sense of value history. If you need to tree each value independently, signal are the wrong pattern and you should look at using observables. |
I wonder when is it expected for the effect to run if the signal didn't change? I mean the logic will probably execute the same as nothing actually changed. |
Effects schedule themeselves via a microtask (+ some extract behaviors in the context of components). Your signal did change twice:
Signals are about being notified eventually when a state is dirty, not individual value updates. |
That's unfortunate... Like computed won't compute if there was no change at the end I thought effect should too... I still can't see a use case for it to be honest |
Computed also re-run with the same usecase. |
At least it is consistent although in my opinion consistently bad. To sum it - this seems unexpected |
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
If I have a signal and an effect:
And later I do:
this.name.set('Angular');
the effect won't run as expected.But doing (in sync):
Will trigger the effect even tough nothing actually changed.
I would expect it not to run...
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-h9xfum?file=src%2Fmain.ts
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: