Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 1.08 KB

no-deeply-nested-dependent-keys-with-each.md

File metadata and controls

31 lines (21 loc) · 1.08 KB

Disallows usage of deeply-nested computed property dependent keys with @each. (no-deeply-nested-dependent-keys-with-each)

For performance / complexity reasons, Ember does not allow deeply-nested computed property dependent keys with @each. At runtime, it will show a warning about this:

WARNING: Dependent keys containing @each only work one level deep. You used the key "foo.@each.bar.baz" which is invalid. Please create an intermediary computed property.

Rule Details

Examples of incorrect code for this rule:

displayNames: computed('todos.@each.owner.name', function() {
  return this.todos.map(todo => todo.owner.name);
})

Examples of correct code for this rule:

displayNames: computed('owners.@each.name', function() {
  return this.owners.mapBy('owner', 'name');
}),

owners: computed('todos.@each.owner', function() {
  return this.todos.mapBy('todo', 'owner');
})

Further Reading