Ember/5/Fpe Computed

1.0.2Last update Jan 10, 2025
by@Codemod
Ember
migration

Before

import EmberObject from "@ember/object";
let Person = EmberObject.extend({
init() {
this._super(...arguments);
this.firstName = "Betty";
this.lastName = "Jones";
},
fullName: function () {
return `${this.firstName} ${this.lastName}`;
}.property("firstName", "lastName"),
});
let client = Person.create();
client.get("fullName"); // 'Betty Jones'
client.set("lastName", "Fuller");
client.get("fullName"); // 'Betty Fuller'

After

import EmberObject, { computed } from "@ember/object";
let Person = EmberObject.extend({
init() {
this._super(...arguments);
this.firstName = "Betty";
this.lastName = "Jones";
},
fullName: computed("firstName", "lastName", function () {
return `${this.firstName} ${this.lastName}`;
}),
});
let client = Person.create();
client.get("fullName"); // 'Betty Jones'
client.set("lastName", "Fuller");
client.get("fullName"); // 'Betty Fuller'

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now