dimanche 23 août 2015

Ember.computed (v2.0.0): get(key), set(key, value)

In Ember v2.0.0 Guide, chapter "THE OBJECT MODEL", section "Computed Properties":

Person = Ember.Object.extend({
  firstName: null,
  lastName: null,

  fullName: Ember.computed('firstName', 'lastName', {
    get(key) {
      return this.get('firstName') + ' ' + this.get('lastName');
    },
    set(key, value) {
      var [ firstName, lastName ] = value.split(/\s+/);
      this.set('firstName', firstName);
      this.set('lastName',  lastName);
    }
  })
});

Please help me understand the constructions "get(key)", "set(key, value)" and "var [ firstName, lastName ] = ...".

New ES6 and/or Ember functionality?




Aucun commentaire:

Enregistrer un commentaire