-
Notifications
You must be signed in to change notification settings - Fork 36
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 array macros work with native JS arrays #384
Conversation
addon/array/uniq-by.js
Outdated
}); | ||
|
||
return ret; | ||
} |
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.
Maybe I don't get why this was necessary but emberA(array)
should really have the same result.
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.
Nice! Simplify all the things :)
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.
Apparently uniqBy
doesn't exist in Ember 1.13: https://travis-ci.org/kellyselden/ember-awesome-macros/jobs/270136987#L2742 😞
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.
#269 for reference
@kellyselden: would be great to get this merged |
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.
Sorry I took so long. Two minor cleanups then good to merge.
@@ -1,7 +1,6 @@ | |||
import { findBy } from 'ember-awesome-macros/array'; | |||
import { raw } from 'ember-awesome-macros'; | |||
import EmberObject from '@ember/object'; | |||
import { A as emberA } from '@ember/array'; |
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.
Should all these lines be reverted now?
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.
indeed, yes - fixed
@@ -12,6 +12,7 @@ export default createClassComputed( | |||
if (array === undefined || key === undefined) { | |||
return array; | |||
} | |||
|
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.
We should probably do a array = emberA(array);
here. That way we skip the polyfill for newer Ember version, and we are more consistent with the other array macros.
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'm not sure what you mean tbh.
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'll fix it in a subsequent PR and tag you.
Thanks a lot. |
The array macros (or most of them) assumed the source arrays to be
Ember.Array
s which I don't think is necessary (and breaks without prototype extensions, e.g. in FastBoot).Although CPs won't update correctly when defined on native JS arrays there's no reason why they should not compute correctly initially (and that's also what Ember's own array CP macros do).