Ember.js 2.3 implement @each.property observer on a HasMany relationship?

后端 未结 2 1044
一向
一向 2020-12-06 08:36

Say I have a hasMany relationship Procedure => hasMany Steps, with async:true, and I have a Procedure Component (on the procedure route) called procedure-main, which lists t

相关标签:
2条回答
  • 2020-12-06 09:12

    You should still use @each

    stepsStatusObserver: Ember.observer('steps.@each.stepStatus', function(){
    ...
    })
    
    0 讨论(0)
  • 2020-12-06 09:39

    The problem is that steps.[].stepStatus is not a valid dependent key anymore. You should replace it by steps.@each.stepStatus.

    Here is a summary of valid and invalid dependent keys in current Ember versions:

    • array - this observes if the array reference itself changes, e.g replacing the entire array with another value or array such as that oldValue !== newValue.
    • array.[] - this observes both when the array itself changes (above) and when the array length changes (functionally equivalent of array.length)
    • array.@each.property - observes both cases above and when property of some of the array's items change
    • array.@each.{prop,anotherProp} - you can also observe multiple properties while specifying only one key. This expands to array.@each.prop and array.@each.anotherProp.
    • array.@each - isn't valid anymore, no trailing @each. Use .[] instead.
    • array.@each.property.property - Also not valid. Note that @each only works one level deep. You cannot use nested forms like todos.@each.owner.name or todos.@each.owner.@each.name.
    • array.[].property - not valid anymore. Use @each form instead.
    0 讨论(0)
提交回复
热议问题