Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating a bound property of a component triggers observers for all bound properties of the component #11491

Closed
laynegt opened this issue Jun 17, 2015 · 11 comments

Comments

@laynegt
Copy link

laynegt commented Jun 17, 2015

This is in 1.13. I have a component with several bound properties from a controller. I also have observers on these properties inside the component. When any of the properties are updated in the controller, the observers for all of the bound properties are fired (in the component, twice).

Example: http://emberjs.jsbin.com/hicowe/edit?html,js,console,output
A and B are bound to properties in the controller. C is an internal property to the component only.

@laynegt laynegt changed the title Updating a bound property of a component triggers observes for all bound properties of the component Updating a bound property of a component triggers observers for all bound properties of the component Jun 17, 2015
@vvisheshd
Copy link

I have exactly the same issue!
http://jsbin.com/yugaxezone/edit?html,js,output .
Observers for all the bound properties are fired and that too TWICE.

http://discuss.emberjs.com/t/ember-1-13-attrs-call-property-change-on-all-observers/8212

@hussasad
Copy link

I am having the same issue. is there any work around for this?

@stefanpenner
Copy link
Member

this is a regression, likely caused by the attrs proxy (or related attrs code).

@rwjblue
Copy link
Member

rwjblue commented Jul 12, 2015

@stefanpenner - Exactly, I agree it is almost certainly related to the attrs proxy.

A little background from a prior spelunking: any time an attribute is changed, we set the entire this.attrs object which then triggers all root attributes via the attrs proxy.

@stefanpenner
Copy link
Member

yes, this new code has issues in 2 phases.

  1. component initialization <-- I am pretty sure I have a solution for this – and i plan to work on this this week. -> Component creation performance is slower in 1.13 than in 1.12 #11502 (comment)
  2. post initialization changes <-- I have an idea, but haven't thoroughly investigated it.

@jcope2013
Copy link
Contributor

seeing same issue

@rounders
Copy link

also seeing this issue.
Ember 1.12 - works as expected:
http://emberjs.jsbin.com/jotacururu/edit?html,js,console,output

Ember 1.13 - initialization of component causes observer to fire and observers fired twice everytime a bound property is changed:
http://emberjs.jsbin.com/nedixehuho/1/edit?html,css,js,output

@tehmaestro
Copy link

Hi, I noticed this too. Also, in the init hook of a component, it seems that if I change a bound property, the observer is not triggered for the parentView. Could this be related?

  // app/controllers/my-controller.js
   propertyChanged: function() {
      //this is not triggered
     console.log('changed');
   }.observes('property')

    // app/templates/my-controller.hbs
    {{my-component property=property}}

    // app/components/my-component.js
   doSomething: function() {
     this.set('property', false);
   }.on('init')

Here, the bound property in the controller is not being updated when the component updates it. I tried to use other component hooks, and it only worked in didInsertElement

Here's some examples
Ember 1.12 outputs "changed" : http://emberjs.jsbin.com/bimerijuko/1/edit?html,js,console,output
Ember 1.13 does not : http://emberjs.jsbin.com/qoxumi/1/edit?html,js,console,output

@rwjblue
Copy link
Member

rwjblue commented Aug 3, 2015

Thanks for providing all these demos/examples, it definitely made it easy to confirm things were fixed here. The double observer firing issue was resolved by #11946.

@rounders - Updated JSBin with current release branch, double firing observers are solved.

@tehmaestro - Your example seems unrelated to this issue (since its about double firing observers), but does seem to be a legitimate issue on its own. Can you report separately?

@vvisheshd - Your JSBin works properly (only fires once) with the latest release builds.

@laynegt - Your JSBin works properly on the latest release builds.

@rwjblue rwjblue closed this as completed Aug 3, 2015
@tehmaestro
Copy link

Thanks for the fix. Opened issue #11967

@rounders
Copy link

rounders commented Aug 4, 2015

@rwjblue, @ef4 👍 thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants