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

Make _recordData lazy #5767

Merged
merged 1 commit into from
Nov 30, 2018
Merged

Make _recordData lazy #5767

merged 1 commit into from
Nov 30, 2018

Conversation

hjdivad
Copy link
Member

@hjdivad hjdivad commented Nov 30, 2018

In particular, do not instantiate them for findRecord

@@ -65,7 +65,12 @@ export default class Snapshot {
*/
this.modelName = internalModel.modelName;

this._changedAttributes = internalModel.changedAttributes();
if (internalModel.isLoading()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this logic belongs in internalModel.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@igorT seems fine; you'd prefer to push this into internalModel.changedAttributes()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly in favor of snapshot since it is request specific logic, but I'm not so heavily in favor as to oppose it being in InternalModel.

Copy link
Member Author

@hjdivad hjdivad Nov 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is request-specific logic; if you have an internal model for a findRecord (ie where isLoading() && !isReloading), what does it even mean conceptually to ask for changed attributes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I reorder that you may see what I mean a little bit better: "logic specific to requests"

Copy link
Member

@igorT igorT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good after comments addressed

@hjdivad hjdivad force-pushed the hjdivad/lazy-recorddata branch from 3f958e7 to 4b070d6 Compare November 30, 2018 02:07
@igorT
Copy link
Member

igorT commented Nov 30, 2018 via email

@hjdivad
Copy link
Member Author

hjdivad commented Nov 30, 2018

@igorT no, root.loading is not empty

@hjdivad
Copy link
Member Author

hjdivad commented Nov 30, 2018

we could change root.loading to isEmpty: true but i am far more wary of that than not eagerly calculating changed attributes during record reload

@hjdivad
Copy link
Member Author

hjdivad commented Nov 30, 2018

@igorT never mind, @runspired pointed me to the isReloading flag within internal model.

@hjdivad hjdivad force-pushed the hjdivad/lazy-recorddata branch from 4b070d6 to d6616eb Compare November 30, 2018 02:15
@runspired
Copy link
Contributor

Relevant for @igorT emberjs/rfcs#359

@runspired runspired merged commit fc68d2a into master Nov 30, 2018
@runspired runspired deleted the hjdivad/lazy-recorddata branch November 30, 2018 02:58
hjdivad added a commit that referenced this pull request Nov 30, 2018
runspired added a commit that referenced this pull request Nov 30, 2018
[BUGFIX beta] backport #5767 Make _recordData lazy
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