-
Notifications
You must be signed in to change notification settings - Fork 286
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
Improve proxies #1053
Improve proxies #1053
Conversation
} | ||
|
||
if (object instanceof Ember.ArrayProxy && object.content && !object._showProxyDetails) { | ||
return this.mixinDetailsForObject(object.slice(0, 101)); |
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.
What is this slice
for?
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.
it does the same as toArray()
, so it obtains the correct items from e.g. ember data many-array but only for the first 101 items, (though this should actually be part of the perf PR). otherwise it would call objectAt
for all items in many-array
@@ -1037,6 +1044,9 @@ function getDebugInfo(object) { | |||
let debugInfo = null; | |||
let objectDebugInfo = get(object, '_debugInfo'); | |||
if (objectDebugInfo && typeof objectDebugInfo === 'function') { | |||
if (object instanceof Ember.ObjectProxy && object.content) { | |||
object = object.content; |
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 wonder if maybe we should use Ember.get
, wouldn't that resolve proxy values as well as normal objects?
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.
but the new ember data debugInfo does not do it...
always fails here:
https://github.com/emberjs/data/blob/master/packages/model/addon/-private/model.js#L1186
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.
@patricklx can you elaborate on that? Perhaps @runspired can help?
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 mean we use Ember.get here get(object, '_debugInfo')
and it will get through the proxy to the _debugInfo
. (in case of accessing belongsTo relation)
but then we bind the _debugInfo
to the proxy itself.
So, this.eachAttribute
will not be there (or should be accessed with Ember.get, if that works to get functions too?) in https://github.com/emberjs/data/blob/master/packages/model/addon/-private/model.js#L1186
Or _debugInfo needs to check if a proxy is beeing used.
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.
but the new ember data debugInfo
I wouldn't call this "new", its been around a long time and it's something we'd love to delete :P
Reaching through the proxy for the content seems wise here.
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.
mmm, right...
but I think it did not happen before... maybe because im using class extends Model {...} instead of Model.extend(...)
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.
no, same issue, so might have never worked with belongTo relations :)
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.
@patricklx this looks good to me! Can you rebase and fix the conflicts please?
@patricklx I fixed the conflicts, but seems like we have some test failures now. |
* improve proxies * fix test
* improve proxies * fix test
* improve proxies * fix test
No description provided.