Ignore initial run of effect()

Discussão em 'Angular' iniciado por tlt, Janeiro 24, 2025.

  1. tlt

    tlt Guest

    we have:

    effect(() => {
    console.log(`Value is ${newValue()}`);
    });


    We don't want whole console.log to run on initial signal set. We want it to run only starting with 2nd change of the signal.

    Should we have a private field initialRun (true initially) in our component and set it to false at the end of our effect() code so that each subsequent run actually executes !initialRun && console.log(....)?

    Or is there any smarter way?

    Continue reading...

Compartilhe esta Página