Skip to content
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

Observing array using array.[] is not working in v1.13.11 #12329

Closed
devinus opened this issue Sep 11, 2015 · 10 comments
Closed

Observing array using array.[] is not working in v1.13.11 #12329

devinus opened this issue Sep 11, 2015 · 10 comments

Comments

@devinus
Copy link
Member

devinus commented Sep 11, 2015

Reproduced here: http://ember-twiddle.com/b663e28c60942f4c3d25

@devinus devinus changed the title Observing array using array.[] is not working Observing array using array.[] is not working in 1.13.11 Sep 11, 2015
@devinus devinus changed the title Observing array using array.[] is not working in 1.13.11 Observing array using array.[] is not working in v1.13.11 Sep 11, 2015
@stefanpenner
Copy link
Member

nothing appears to be consuming allValues doing so makes everything work. This appears to be working as expected?

@stefanpenner
Copy link
Member

also 'allValues', 'allValues.[]', is redundant as observing 'allValues.[]' is a superset of 'allValues'

@devinus
Copy link
Member Author

devinus commented Sep 11, 2015

@stefanpenner valuesDidChange is consuming allValues.

@devinus
Copy link
Member Author

devinus commented Sep 11, 2015

Is this a case of too aggressive optimization? I have an observer observing a computed property, is that not enough to trigger a consumption?

@devinus
Copy link
Member Author

devinus commented Sep 11, 2015

A simpler example: http://ember-twiddle.com/b663e28c60942f4c3d25

@stefanpenner
Copy link
Member

@stefanpenner valuesDidChange is consuming allValues.

yes, but valuesDidChange only fires, if allValues has already been consumed and then changes.

@devinus
Copy link
Member Author

devinus commented Sep 11, 2015

@stefanpenner So, the takeaway is you cannot observe a computed property unless that computed property is consumed elsewhere?

@stefanpenner
Copy link
Member

@stefanpenner So, the takeaway is you cannot observe a computed property unless that computed property is consumed elsewhere?

Yes correct, think of them as Schrödingers Computed Properties. Before consumed, the state is undefined, and as such no state change notification is possible.

The laziness invariant is actually quite nice, but results in the single caveat we just discussed.

@devinus
Copy link
Member Author

devinus commented Sep 11, 2015

@stefanpenner So what's the correct way to do this then? Am I going to have to <div class="hidden">{{allValues}}</div> to get this to work?

@stefanpenner
Copy link
Member

@devinus or you can call this.get('values'); // force eagerness of CP in init() after _super()

@devinus devinus closed this as completed Sep 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants