Arrow functions should not be used in computed properties because they are unable to access other properties (using this.property
) of the same object. Accidental usage can thus lead to bugs.
import EmberObject, { computed } from '@ember/object';
const Person = EmberObject.extend({
fullName: computed('firstName', 'lastName', () => {
return `${this.firstName} ${this.lastName}`;
})
});
import EmberObject, { computed } from '@ember/object';
const Person = EmberObject.extend({
fullName: computed('firstName', 'lastName', function () {
return `${this.firstName} ${this.lastName}`;
})
});