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 array macros work with native JS arrays #384

Merged
merged 2 commits into from
Sep 8, 2017
Merged

Make array macros work with native JS arrays #384

merged 2 commits into from
Sep 8, 2017

Conversation

marcoow
Copy link
Contributor

@marcoow marcoow commented Aug 30, 2017

The array macros (or most of them) assumed the source arrays to be Ember.Arrays 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).

});

return ret;
}
Copy link
Contributor Author

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.

Copy link
Contributor

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 :)

Copy link
Contributor Author

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 😞

Copy link
Owner

Choose a reason for hiding this comment

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

#269 for reference

@marcoow
Copy link
Contributor Author

marcoow commented Sep 1, 2017

@kellyselden: would be great to get this merged

Copy link
Owner

@kellyselden kellyselden left a 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';
Copy link
Owner

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?

Copy link
Contributor Author

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;
}

Copy link
Owner

@kellyselden kellyselden Sep 7, 2017

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.

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'm not sure what you mean tbh.

Copy link
Owner

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.

@kellyselden
Copy link
Owner

Thanks a lot.

@kellyselden kellyselden merged commit 9bc537c into kellyselden:master Sep 8, 2017
@marcoow marcoow deleted the fix-array-macros branch September 8, 2017 16:23
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