Why use linkedSignal instead of computed in Angular Signals?

Discussão em 'Angular' iniciado por אילה וינשטוק, Novembro 23, 2024.

  1. I am 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.

    Continue reading...

Compartilhe esta Página