1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Is using transloco 't' function from the directive calling the function every time on change...

Discussão em 'Angular' iniciado por zvocs, Novembro 8, 2024 às 06:22.

  1. zvocs

    zvocs Guest

    I was wondering about this issue about the "t" function transloco uses in its directive.

    When we use functions in our template in angular for, lets say, showing users email. So we write something like:

    <div>
    {{getUserEmail()}}
    </div>


    From my knowledge of angular, unless you put OnPush detection strategy, this function will get called on every change detection. This is why it's recommended to use pipes when possible because they are not subject to this problem.

    So my question is, does the 't' function of transloco somehow avoid this call every time or not? Or am I missunderstanding transloco/angular?

    P.S. I know the function is memoized but it would still be better if it's not called every change detection.

    I'm considering using transloco pipe mostly because it seems to me like it's better to have more subscriptions in the app then having "t" function called a bunch of times. Maybe my perception is wrong?

    Continue reading...

Compartilhe esta Página