lundi 23 janvier 2017

bug ember computed with setter and getter

so. I have this in my component.js :

…
inputs: Ember.A(),

inputGroup: computed('inputs.[]', {
    get() {
      return this.get('inputs').mapBy('value');
    },
    set(_, values) {
     # breakpoint 1
      if (values) {
        values.forEach(value => {
          this.get('inputs').addObject({ id: Symbol(), value: value });
        });
      }
     # breakpoint 2
      return this.get('inputs').mapBy('value');
    },
  }),
...

and I have 2 of this component in my app.hbs :

 

with app.js :

…
firstGroup: Ember.A([’text@text.com’]),
secondGroup: Ember.A(),
…

in my first component, debugger on # breakpoint 1, inputs === [], on # breakpoint 2, inputs === ['test@test.com'] in my second one, debugger on # breakpoint 1, already inputs === [‘text@text.com’]. How is that possible ??




Aucun commentaire:

Enregistrer un commentaire