-
-
Notifications
You must be signed in to change notification settings - Fork 500
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
updates more get
instances and language in object model
#124
Conversation
ae0ab0d
to
545aae4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cspanring I suggested some minor changes to wording. Can you rebase/merge in master
now that the other PR is in? I think some of the changes are taken care of.
and [`set()`][8] accessor methods: | ||
When reading a property value of an object, you can in most cases use the common Javascript dot notation, e.g. `myObject.myProperty`. | ||
|
||
The one big exception to this rule are [Ember proxy objects][9]: if you're working with Ember proxy objects, including promise proxies for async relationships in Ember Data, you have to use Ember's [`get()`][7] accessor method to read values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight edit:
[Ember proxy objects][9] are the one big exception to this rule. If you're working with Ember proxy objects, including promise proxies for async relationships in Ember Data, you have to use Ember's [get()
][7] accessor method to read values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think maybe we need a small example here.
For example, say there is an Ember Data model, blogPost
, which has many comment
records associated with it. We could access attributes of the blogPost
itself using dot notation, like blogPost.title
. However, to show the comments that are part of the relationship, we would need to use blogPost.get('comments')
.
|
||
The one big exception to this rule are [Ember proxy objects][9]: if you're working with Ember proxy objects, including promise proxies for async relationships in Ember Data, you have to use Ember's [`get()`][7] accessor method to read values. | ||
|
||
For updating property values use Ember's [`set()`][8] method. It will propagate the value change to computed properties, observers, templates, etc. If you "just" use Javascript's dot notation to update a property value, computed properties won't recalculate, observers won't fire and templates won't update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise, I suggest that you flip the order of this sentence. "Always use Ember's [set()
][8] method to update property values."
545aae4
to
f11a660
Compare
@jenweber thanks for your feedback! rebased, updated the language and added a simple Ember Data example to that section. please have a look again. |
Thanks Christian! |
Attempt to check off task 2 in emberjs/guides#2303 and update some of the language around
get
andset
, including when to and when not to use it.@jenweber please have a look. might conflict slightly with #122