#Component Effect timing is different with property binding and literal value syntax ?

22 messages · Page 1 of 1 (latest)

obsidian surge
solemn orchid
#

This one gave me a head scratch for a good 15min 😄

#

This is due to you mutating the array and Angular not applying the interpolation because the array reference didn't change

#

The effect just run fine

#

Also there is a little timing difference between a binding and a static attribute.
The static attribute is accessible earlier, as you can see when the effect parent effect runs

obsidian surge
#

Right, thats a bad example - I wanted to showcase the fact, that when there is a property binding, the component you get from view child query has still its initial value for the input, while when there is an attribute, its set.

#

I will change the example

obsidian surge
#

The example should be clearer now

solemn orchid
#

in your transform your input into a required input you fall into the same situation, the binding just throws.

obsidian surge
#

So its expected behavior and requires userland handling?

solemn orchid
#

It's a bug

#

I just posted a narrowed down repro of the root issue

obsidian surge
#

ye thats exactly what I showcased

#

ok nice!

solemn orchid
#

Yes, it's based on your issue

#

It clearly shows that it's a querying issue, not an effect one

obsidian surge
#

From my point of view I think the timing of the effect is unlucky - it should be executed first, when the inputs have been set, so that initial values must not be handled by the effect or in other words the side effect is not triggered with a useless value since right after the first execution the real value gets set and triggers the effect again.

#

viewChild() is just a signal, it does not know that it should not notify the effect i guess

#

maybe component effects can filter out triggers until all children have run on init

solemn orchid
#

effect just follows the reactivity. The query shouldn't be populated (and thus not trigger the effect) until the components/directives have their inputs set