What capacity does the linked signal in Angular 19 have that the computed signal in Angular 18...

Discussão em 'Angular' iniciado por Konrad Viltersten, Novembro 23, 2024.

  1. I've seen the official docs as well as a bunch of lyrical blogs. Despite that, I still can't understand what's the big hoopla is. I do understand what linkedSignal and computed are. What I do not get is how they're different.

    It's said that the limitation of the latter is that it's not writeable. Correct. But in what way is the former writable? We can't do linky.set("shazoo"), can we? It's only possible for it to react to a change in another signal and then, produce a recomputed value to its consumer. However, that's precisely what the other does.

    Angular 18: using computed signal.

    export class Angy18 {
    ...
    siggy = signal(1);
    compy = computed(() => siggy() * 2);
    }


    Angular 19: using linked signal.

    export class Angy19 {
    ...
    siggy = signal(1);
    linky = linkedSignal({
    source: this.siggy;
    computation: () => siggy() * 2);
    });
    }


    To me, it appears that the only difference is the verbose multi-line syntax is required. I'm certain that the gain of linked signals lies elsewhere. Please help me understand what the ignorant me is missing.

    Continue reading...

Compartilhe esta Página