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

For a resource, update its underlying data only if the API data is different than its current data. #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yadavsaroj
Copy link
Contributor

No description provided.

Ember.set(objA, key, newValue);
oldValueEmptyArray = (Ember.typeOf(oldValue) == "array") && (oldValue.length == 0)
newValueEmptyArray = (Ember.typeOf(newValue) == "array") && (newValue.length == 0)

Copy link
Collaborator

Choose a reason for hiding this comment

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

You could use Em.compare to compare the two arrays (guarded by an isArray). There's also isEqual, which doesn't seem to work for arrays afaict.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not comparing the actual contents of an array, all I am checking is if they both are empty. Em.compare though can be used, seems to be an overkill for that.

btw just checked if Em.compare looks into actual array contents, unless I am missing something does not look like that as
Em.compare([{k1:1}], [{k1:111}]) returns 0, the value it returns if both objects being compared are equal.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, yeah compare can't be used here. So this is meant to support just empty arrays and scalars? (i.e it will skip arrays with values and objects)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes! It won't compare non empty arrays.

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.

2 participants