Latest updates to effect() in ... Note

Latest updates to effect() in Angular

Angular's developer preview process allows developers to try out APIs and features before they are promoted to production, and enables the Angular team to adjust those APIs based on real-world usage and feedback. Through feedback on the effect() API, the team has identified several improvements to the design that will address real issues with functionality and developer experience. One of the changes is the removal of the allowSignalWrites flag, which was intended to encourage good patterns but ultimately discouraged usage of effect() in cases where it would be reasonable to update signals. Instead, the team will focus on other ways of encouraging good patterns, including the addition of new reactivity helpers where needed. The timing of when effects run is also being changed, with effects now running as part of the component hierarchy during change detection. This change aims to make effect timing more predictable and useful, and resolve bugs around effects running too early or too late. Most uses of the effect API will continue to work as expected, but some use cases may be impacted, such as effects against view query results and toObservable() of input signals. The Angular team has fixed around 100 cases where the timing change meaningfully impacted code during testing at Google. As a result of these changes, the effect() API will remain in developer preview through at least v19.0, with plans to stabilize the API in an upcoming minor release. The Angular team thanks the community for their feedback and support, which has played a crucial role in the development of Angular.