-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Property get and set in component init breaks computed property #13945
Comments
I think this is a duplicate of #13823. I moved the In the mentioned issue this is the comment with the explanation about how init works. If you are OK with this, I'll close the issue. |
Thanks @Serabe! It looks like it probably has the same/similar root cause, but I think this is a more regular use case in that even local properties (i.e. not trying to propagate back up to the parent view) are also affected. I think it more broadly means that you can't reliably do property initialization in the However, I'd be glad to follow-up on that other issue and close this one if you think they're sufficiently similar. |
Let's see what @krisselden thinks about this one. It is a bit strange because the Thank you! |
On the init method ordering matters, no change events fire and you cannot rely on events to sort out dependencies between props. It is supposed to be initializing the object to its initial state, you have to be aware of the order and shouldn't leak out the partially initialized object to code that expects a fully initialized object |
The init event fires when initialize is done and all events are enabled at that point |
Thank you, @krisselden. I will close this then. |
I don't think this is too common of a pattern of initializing properties in an
init
method of a component, but caught me by surprise today.If a computed property is
get
'd before its dependency isset
in theinit
method of a component (or anytime before the component is fully initialized), the value from theget
is cached and not invalidated.See this twiddle for three examples in
my-component
:https://ember-twiddle.com/63798c90dba1839c1631ce6991ac74df?openFiles=components.my-component.js%2Ctemplates.components.my-component.hbs
I would have expected all three
isTrue
computed properties to betrue
, however the one that isget
andset
within theinit
block doesn't seem to be properly recomputed.This might be related, but I am not certain: #1789. This also seems to describe the issue: #3399, however because of #5120, this doesn't affect
computed.alias
anymore, but "normal" computed properties are still impacted.The text was updated successfully, but these errors were encountered: