Stop Misusing Effects! Linked Signals Are the Better Alternative!
State synchronization with Angulars brand new linked Singlas API for a cleaner and more maintainable approach.
![Kevin Kreuzer](/assets/images/experts/kevin-kreuzer-gde.webp)
Kevin Kreuzer
@kreuzercode
10.02.2025
4 min read
![Stop Misusing Effects! Linked Signals Are the Better Alternative!](https://angularexperts.imgix.net/blog/stop-misusing-Effects/title-16x9.webp?auto=format)
With Angular’s renaissance and the rise of new reactive state management tools like Signals and Effects, developers often turn to Effects for state synchronization.
While Effects have their place, they are not primarily designed to keep state in sync, and relying on them for this purpose can lead to unnecessary complexity.
Angular 19 introduces linked Signals, a powerful addition to the framework’s reactive toolkit that provides a cleaner alternative to managing state. Unlike computed signals, which only derive values reactively, linked Signals offer writable state — allowing manual updates when needed while maintaining reactivity.
In this post, we’ll explore why Effects can be an anti-pattern, how linked Signals provide a more maintainable approach, and how you can use them to improve your Angular apps. 😉
The Challenge of state synchronization
Let’s take a common example: A ProductChooserComponent
that allows users to select a product and specify a quantity. Here’s a screenshot of such an application.
![Product chooser demo application](assets/images/blog/stop-misusing-effects/product-chooser.webp)
Clicking the plus button triggers the addProduct
function, adding a new product. The total
updates automatically whenever an item is added or removed.
export class ProductCardComponent {
product = input.required<Product>();
amount = signal(1);
total = computed(() => this.amount() * this.product().total);
nextProduct = output<void>();
previousProduct = output<void>();
addProduct() {
this.amount.update(v => v + 1);
}
removeProduct() {
this.amount.update(v => v - 1);
}
}
The ProductCardComponent
is a reusable component, meaning it accepts a product
as input. If we switch the product — using an Angular output in the template to emit nextProduct
or previousProduct
— only the product updates, while the amount
remains unchanged.
In other words, If a user adds 4
items of one product and then selects another, the amount remains at 4
instead of resetting. This results in unintended behavior. We need a way to ensure the amount
updates in sync with the new product.
The Wrong Approach: Misusing Effects
One way to address this is to use an effect
to reset the amount when the product changes:
#resetAmountEffect = effect(() => {
this.product();
this.amount.set(1);
});
While this works, it misuses Effects for state management. The issues with this approach include:
❌ Misuse of Effects: Effects are meant for handling side Effects (e.g., API calls, external updates), not for deriving or managing state.
❌ Separation of Concerns: Using Effects for state derivation blurs concerns, making the code harder to maintain and understand.
⚠️ Potential for Glitches: Since Effects run asynchronously, they introduce a risk of inconsistent states, which can lead to unexpected behavior.
The Better Solution: linked Signals ✅
Instead of an effect, we can use the new linked signal API, which is designed for state synchronization. Let’s refactor our component.
export class ProductCardComponent {
product = input.required<Product>();
amount = linkedSignal({
source: this.product,
computation: () => 1,
});
addProduct() {
this.amount.update(v => v + 1);
}
removeProduct() {
this.amount.update(v => v - 1);
}
}
With this approach, the amount automatically resets when the product changes, while still allowing updates when adding or removing a product.
✅ Immediate updates: No async execution delays or glitches.
✅ Cleaner code: Avoiding unintended side Effects that disrupt state management.
By using linked Signals, we eliminate the effect entirely and simplify the logic while achieving the same behavior.
Beyond the Basics
The example above is just a glimpse of what’s possible with linked Signals. Want to explore more? Want to dive deeper into the linked Signals API? Check out our brand-new Angular Signals Masterclass eBook, where we dive into topics such as:
More complex computation functions that rely on both source and previous values.
Using linked Signals for client-side updates of fetched data to implement optimistic vs. pessimistic updates.
If you’re serious about writing modern, reactive, and maintainable Angular applications, mastering Signals is a must. This book covers everything you need to know — from why Signals matter to linked Signals and the roadmap ahead.
TL;DR
✅ Linked Signals allow you to derive state from a source signal while keeping it writable.
✅ Linked Signals eliminate the need for Effects when synchronizing state.
✅ Linked Signals simplify state management for dynamic UI interactions.
✅ Stop using Effects for state updates — use linked Signals instead!
Let me know what you think in the comments! Have you tried linked Signals yet? How are you using them in your Angular apps? 🔥
Do you enjoy the theme of the code preview? Explore our brand new theme plugin
Skol - the ultimate IDE theme
Northern lights feeling straight to your IDE. A simple but powerful dark theme that looks great and relaxes your eyes.
Prepare yourself for the future of Angular and become an Angular Signals expert today!
Angular Signals Mastercalss eBook
![Angular Signals Mastercalss eBook](assets/images/products/ebook-signals/product-placement.webp)
Discover why Angular Signals are essential, explore their versatile API, and unlock the secrets of their inner workings.
Elevate your development skills and prepare yourself for the future of Angular. Get ahead today!
Get notified
about new blog posts
Sign up for Angular Experts Content Updates & News and you'll get notified whenever I release a new article about Angular, Ngrx, RxJs or other interesting Frontend topics!
We will never share your email with anyone else and you can unsubscribe at any time!
Responses & comments
Do not hesitate to ask questions and share your own experience and perspective with the topic
![Nivek - GDE for Angular & Web Technologies](assets/images/experts/kevin-kreuzer-gde.webp)
Nivek
GDE for Angular & Web Technologies
Trainer, Berater und Senior Front-End Engineer mit Schwerpunkt auf dem modernen Web. Er ist sehr erfahren in der Implementierung, Wartung und Verbesserung von Anwendungen und Kernbibliotheken für große Unternehmen.
Kevin ist ständig dabei, sein Wissen zu erweitern und zu teilen. Er unterhält mehrere Open-Source-Projekte, unterrichtet moderne Webtechnologie in Workshops, Podcasts, Videos und Artikeln. Weiter ist er ein beliebter Referent auf Konferenzen. Er schreibt für verschiedene Tech-Publikationen und war 2019 der aktivste Autor der beliebten Angular In-Depth Publikation.
58
Blog posts
2M+
Blog views
39
NPM packages
4M+
Downloaded packages
100+
Videos
15
Celebrated Champions League titles
You might also like
Check out following blog posts from Angular Experts to learn even more about related topics like Modern Angular !
![Hawkeye, the Ultimate esbuild Analyzer](https://angularexperts.imgix.net/blog/hawkeye-esbuild-analyzer/title-16x9.webp?auto=format)
Hawkeye, the Ultimate esbuild Analyzer
Effortlessly analyze your JS bundles and uncover actionable insights to boost performance and enhance user experience.
![Kevin Kreuzer](/assets/images/experts/kevin-kreuzer-gde.webp)
Kevin Kreuzer
@kreuzercode
28.12.2024
10 min read
![My new Angular Coding Style](https://angularexperts.imgix.net/blog/new-angular-coding-style/title-16x9.webp?auto=format)
My new Angular Coding Style
Embracing the New Angular: A Fresh Perspective on how to write Angular code.
![Kevin Kreuzer](/assets/images/experts/kevin-kreuzer-gde.webp)
Kevin Kreuzer
@kreuzercode
02.12.2024
7 min read
![Top 10 Angular Architecture Mistakes You Really Want To Avoid](https://angularexperts.imgix.net/blog/top-10-angular-architecture-mistakes/title-16x9.webp?auto=format)
Top 10 Angular Architecture Mistakes You Really Want To Avoid
In 2024, Angular keeps changing for better with ever increasing pace, but the big picture remains the same which makes architecture know-how timeless and well worth your time!
![Tomas Trajan](/assets/images/experts/tomas-trajan-gde.webp)
Tomas Trajan
@tomastrajan
10.09.2024
15 min read
Stärken Sie Ihr Team mit unserer umfassenden Erfahrung
Unsere Angular Experten haben viele Jahre damit verbracht, Unternehmen und Startups zu beraten, Workshops und Tutorials zu leiten und umfangreiche Open-Source-Ressourcen zu pflegen. Wir sind sehr stolz auf unsere Erfahrung im Bereich des modernen Frontends und würden uns freuen auch Ihrem Unternehmen zum Aufschwung zu verhelfen.