Dev.to•Jan 28, 2026, 6:20 PM
Angular v21's effects: the loyal signal watcher that batches your side effects, so you only crash once instead of three times

Angular v21's effects: the loyal signal watcher that batches your side effects, so you only crash once instead of three times

In the latest version of Angular, version 21, a key concept is the "effect", a function that automatically runs when the signals it uses change. An effect is defined using the effect() function, typically inside a component's constructor, and is designed for "side effects" such as logging, saving files, or updating charts. Unlike other signals, an effect does not return a value, but instead performs a task. Effects are asynchronous and batched, meaning they trigger only once after all dependent signals are updated, and are commonly used for logging, analytics, and external API interactions. Angular enforces safety rules for effects, including no signal writes by default, to prevent infinite loops. Effects can also be used with async functions and provide an onCleanup function to stop tasks before the next run. This feature allows developers to efficiently manage side effects in their applications, making it a significant addition to the Angular framework.

Viral Score: 75%

More Roasted Feeds

No news articles yet. Click "Fetch Latest" to get started!