mercredi 17 juin 2015

Ember 1.13 Attrs call property change on all observers

I have a component like:

    App.TestCompComponent = Ember.Component.extend({
    title: Test Component,

    disablePastChanged: function(){
        alert('disable past changed');
    }.observes('disablePast').on('init'),

    prop1Changed: function(){
        alert('Prop1 changed');
    }.observes('prop1').on('init')
});

and handlebars template as:

        {{#test-comp disablePast=disablePast prop1=prop1}}
        {{/test-comp}}

Now when a set any property/attrs on this component from parent component like this.set('disablePast', false), both observers are fired (essentially all the attrs observers are fired). Is that the right behavior? As far i am concerned it should have fired just the property/attrs which changed.

JS Bin here -- Why It fires the observers on startup, those properties are not being set anywhere? When you click on the button and it sets only one property/attrs it fires observer twice for the properties.

What am i doing wrong here??

Thanks!

Aucun commentaire:

Enregistrer un commentaire