vendredi 11 mars 2016

Why do ember computed properties only execute once in ember inspector?

I have a demo controller:

import Ember from 'ember';

export default Ember.Controller.extend({
  firstName: 'Bob',
  lastName: 'Smith',

  emailAddress: 'bobsmith@gmail.com',

  fullName: Ember.computed('firstName', 'lastName', function() {
    console.log('executed!');
    return `${this.get('firstName')} ${this.get('lastName')}`;
  }),

  actualEmailAddress: Ember.computed('emailAddress', function() {
    console.log('actualEmailAddress function is called: ', this.get('emailAddress'));
  })
});

When I'm running the app on localhost in the browser, I open ember inspector and run:

$E.get('actualEmailAddress')

This returns:

actualEmailAddress function is called: bobsmith@gmail.com

But when I run it a second time I just get undefined

Same thing when I run $E.get('fullName')

It returns

executed!
"Bob Smith"

But then when I run it again it only returns Bob Smith, not the console.log

Why is this happening?

Thank you!




Aucun commentaire:

Enregistrer un commentaire