Design Properties of Aurelia with ES5

I am working on an Aurelia tutorial, but I intentionally use only ES5 and AMD / RequireJS, as I am initially trying to reduce the technical overload that I might need to introduce in my current production application (which currently uses Angular, but I'm considering exchanging for Aurelia instead Angular 2), but I'm stuck with working with computed properties.

I noticed that an update in April removed the computed function from the Object prototype, which allowed the following syntax to be used, but I have nothing to do instead of the following syntax:

Welcome.computed({
    fullName : function() { return this.firstName + " " + this.lastName; }
});

I can achieve the same effect with the following, but it seems pretty verbose, given what is being achieved! Is there a proper way to Aurelia?

Object.defineProperty(
  Welcome.prototype,
  "fullName",
  {
    get: function() { return this.firstName + " " + this.lastName },
    enumerable: true
  });
+4
1

, , - factory, ES5 .

. :

ES5:

function fullName() { return this.firstName + ' ' + this.lastName }
fullName.dependencies = ['firstName', 'lastName'];
Object.defineProperty(
  Welcome.prototype,
  'fullName',
  {
    get: fullName,
    enumerable: true
  });

ES6/ES7:

@computedFrom('firstName', 'lastName')
get fullName() {
  return `${this.firstName} ${this.lastName}`;
}

http://aurelia.io/docs.html#adaptive-binding

+3

All Articles