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 nested objects properties in ArrayProxy fails when using @each, works with explicit index #12328

Closed
e00dan opened this issue Sep 11, 2015 · 7 comments
Labels

Comments

@e00dan
Copy link
Contributor

e00dan commented Sep 11, 2015

Observing nested objects properties in ArrayProxy fails when using @each, works with explicit index like 0.

Having ArrayProxy:

testData: Ember.ArrayProxy.create({
    content: [
      Ember.Object.create({
        secondValue: testObj.create({
          val: true
        })
      })
  ]

This fires correctly when property changes (using concrete index - 0 and content):

arrayChangedExplicitly: Ember.observer('testData.content.0.secondValue.val', function () {
    console.log('Array changed with 0 index explicitly');
}),

This doesn't (using each and content):

arrayChangedEach: Ember.observer('[email protected]', function () {
    // this does not work!
    console.log('Array changed with each');
}),

Neither:

arrayChangedEachNoContent: Ember.observer('[email protected]', function () {
    // this does not work!
    console.log('Array changed with each');
})

Using Ember version:

DEBUG: -------------------------------
DEBUG: Ember  : 2.1.0-beta.3
DEBUG: jQuery : 1.11.1
DEBUG: -------------------------------
  1. SEE DEMO ON JSBIN.
  2. Open dev tools and console F12
  3. Toggle checkbox by clicking on it
  4. Following will be logged:
Array changed with 0 index explicitly - from array nested objects observer
valChanged observer in object - from observer in object

Issue is that:

Array changed with @each

isn't logged, and using @each in observing objects properties in ArrayProxy doesn't work.

@devinus
Copy link
Member

devinus commented Sep 11, 2015

I believe this might be related: #12329

@e00dan
Copy link
Contributor Author

e00dan commented Sep 11, 2015

Yes, I also thought of referencing this issue in your issue.

@pixelhandler
Copy link
Contributor

@kuzirashi I don't believe observing nested properties are supported '[email protected]' but instead only '[email protected]' is supported (but that should be property of the object not a object itself.

See: http://guides.emberjs.com/v1.13.0/object-model/computed-properties-and-aggregate-data/

Note that @each only works one level deep. You cannot use nested forms like [email protected] or [email protected][email protected].

@stefanpenner
Copy link
Member

Note that @each only works one level deep. You cannot use nested forms like [email protected] or [email protected][email protected].

this is actually meant to say you cant do. [email protected].@each but [email protected] should work.

@krisselden
Copy link
Contributor

Using dependencies [email protected].@each and [email protected] have never been supported by any version of Ember and not covered by any test. Only thing is to work without issue is to decompose into multiple CPs.

@stefanpenner
Copy link
Member

Using dependencies [email protected].@each and [email protected] have never been supported by any version of Ember and not covered by any test. Only thing is to work without issue is to decompose into multiple CPs.

@stefanpenner
Copy link
Member

i believe @rwjblue is going to be adding a warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants