Member-only story

Why use linkedSignal instead of computed in Angular Signals?

Learn_With_Awais
2 min readDec 3, 2024

--

Question

Trying to understand the differences between linkedSignal and computed in Angular’s Signals system, and why linkedSignal would be preferred in certain situations.

For example, if I want to manage a selectedOption that depends on shippingOptions, why not use computed like this:

const shippingOptions = signal(['Ground', 'Air', 'Sea']);
const selectedOption = computed(() => shippingOptions()[0]);

Why linkedSignal is a better choice in scenarios like this?

I haven’t tried implementing this yet — I’m trying to understand the conceptual differences between linkedSignal and computed. Based on what I understand, computed should work fine for dependent state. I’m wondering what makes linkedSignal a better option in Angular’s Signals system.

Answer

A linkedSignal is a writable signal that is already derived from another reactive expression.

Indeed :

const selectedOption = linkedSignal(() => shippingOptions()[0]);

is the same as

const selectedOption = computed(() => shippingOptions()[0]);

--

--

Learn_With_Awais
Learn_With_Awais

Written by Learn_With_Awais

“Angular Developer | Tech Enthusiast | Sharing insights on modern web development, AI tools, and productivity hacks. Let’s build smarter, together! 🚀”

Responses (4)