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

[BUGFIX canary] Trust Ember.set #12247

Merged
merged 1 commit into from
Sep 1, 2015
Merged

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Aug 30, 2015

This change eliminates unnecessary dirtying of proxy streams when the
source object is an Ember.Object. It results in significant re-render
performance improvement in certain scenarios, especially when people are
iterating over lists of Ember.Objects to render components with
expensive lifecycle hooks.

We already have a longstanding convention that people need to use set
to mutate Ember.Objects if they expect any observability, and as long as
people are using set, interior mutability will be captured by other
observers further downstream.

The same is not necessarily true for POJOs. We would like to allow
something conceptually like:

myComponent.set('thing', aPojo);
aPojo.deep.inside.here = 'newValue';
myComponent.notifyPropertyChange('thing');

to work correctly, such that the deep mutation gets noticed. Which is
why this change treats POJOs and Ember.Object's differently.

Credit to @wycats for formulating this approach.

This change eliminates unnecessary dirtying of proxy streams when the
source object is an Ember.Object. It results in significant re-render
performance improvement in certain scenarios, especially when people are
iterating over lists of Ember.Objects to render components with
expensive lifecycle hooks.

We already have a longstanding convention that people need to use `set`
to mutate Ember.Objects if they expect any observability, and as long as
people are using `set`, interior mutability will be captured by other
observers further downstream.

The same is not necessarily true for POJOs. We would like to allow
something conceptually like:

    myComponent.set('thing', aPojo);
    aPojo.deep.inside.here = 'newValue';
    myComponent.notifyPropertyChange('thing');

to work correctly, such that the deep mutation gets noticed. Which is
why this change treats POJOs and Ember.Object's differently.
@rwjblue
Copy link
Member

rwjblue commented Aug 30, 2015

This seems good (certainly OK to land on canary for us to work through on the way to 2.2.0-beta.1 in a few weeks).

FWIW, I am not a huge fan of the usage of instanceof (it has bit us many times), and would prefer to see something like isEmberObject (which is what we have done for many other things like this).

@rwjblue
Copy link
Member

rwjblue commented Sep 1, 2015

@wycats - r?

@wycats
Copy link
Member

wycats commented Sep 1, 2015

@rwjblue big r+ from me. This is one of the two changes I've been harping on since the last Face to Face.

rwjblue added a commit that referenced this pull request Sep 1, 2015
[BUGFIX canary] Trust Ember.set
@rwjblue rwjblue merged commit 4fbc27d into emberjs:master Sep 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants