Weird bug(?) with components

Hi,

I had this weird thing happening in my app, so I investigated and created the simplest ember-twiddle I could to reproduce this.

In short: Can you explain why there are A’s in the string and not only B’s???

Basically I have two components A and B. A renders B and passes it a ‘counter’ and field1 with an initial value (“A”). The counter is incrementing every second.

Component B is observing the counter and setting field1 to “B” upon a change in counter. The component also observes the property ‘field1’ and logs it value.

For some reason you can see the value of ‘field1’ is reverting to ‘A’ each time I try to set it to ‘B’

Is that normal??

Just a guess, but everytime you change the value the component is rerendered to reflect the new value isn’t it, which means the helper setting it to A again will be firing the logger because you are observing on init?

Thanks! That is probably it!

I added an “didRender” function and it is being called every time.

I did not expect the field1 value to be initialized every time… I learn new things about Ember every day… wow

1 Like