[FEATURE uniqBy] Adds Enumerable.uniqBy and Computed.uniqBy#12875
[FEATURE uniqBy] Adds Enumerable.uniqBy and Computed.uniqBy#12875rwjblue merged 1 commit intoemberjs:masterfrom
Conversation
There was a problem hiding this comment.
@rwjblue im assuming this code/docs also needs to be feature flagged?
There was a problem hiding this comment.
Yes, the docs should be inside the feature flags.
|
Thanks for the continued polish on this @seanjohnson08 :-) |
|
We should also ensure that a module is added to ember-cli-shims when Ember.computed.uniqBy is present. |
|
@mixonic thanks for all of the feedback/help. One last issue: When I flag off |
|
You have to also flag the new tests to only run when the feature is enabled. Then you can check the checkbox in the test runner environment for "enable optional features". |
|
Alright - so I've moved the tests to the right place, but I don't believe I'm flagging off the tests correctly. They all pass locally (with |
There was a problem hiding this comment.
I uncommented this out only because it was messing with my editor's formatting, I've added it back. Good catch. :)
|
I believe the current failures are due to caching of glimmer-engine, which should have been fixed by #12882. Can you rebase? Also, before merging we will need to squash these commits down to a single commit with a prefix of |
1094923 to
e9d6bc7
Compare
|
@rwjblue - rebased and squashed. |
37b8074 to
572895b
Compare
|
should be good to go now - thanks for all of your help/feedback. 👍 |
|
☔ The latest upstream changes (presumably #12575) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@rwjblue - I've resolved conflicts, any further discussion on the fate of this PR? |
|
Should be good, will review one last time... |
|
+1. It would be a good computed feature to have. |
|
☔ The latest upstream changes (presumably #12991) made this pull request unmergeable. Please resolve the merge conflicts. |
9e307a5 to
7348dce
Compare
|
I've once again rebased on latest changes - the latest commit included @mmun's |
|
@seanjohnson08 WeakMap is not intended to be used as a short-lived object. This leaks memory. Please see the comment at ember.js/packages/ember-metal/lib/weak_map.js Lines 17 to 21 in 4a404de Fortunately the fix is simple. Just use a
|
7348dce to
8585dc4
Compare
|
☔ The latest upstream changes (presumably #13100) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@seanjohnson08 this is very much still a go. Can I ask you for a fresh rebase? I'm checking through the implementation again, but we are likely good to go!! |
There was a problem hiding this comment.
Wasn't @mmun asking that this use EmptyObject instead of {}? Can we do that?
There was a problem hiding this comment.
I've rebased and switched to EmptyObject. Thanks!
1d84cf8 to
643b101
Compare
|
Thank you @seanjohnson08! |
ORIGINAL PR: #12758
Almost all of the enumerable methods that serve to produce some new result from a list follow the following pattern:
filterfilterBymapmapByfindfindByrejectrejectByuniqExcept
uniq! My proposal is to add auniqBymethod to both theEnumerableclass and to the computed reduce macros to allow the user to reduce a list down to its unique values given some key. A prime example is if I'm dealing with a list of records, or objects returned that have a primary key:var records = Ember.A([ {id: 1, name: 'Adam' }, {id: 2, name: 'Eve' }, {id: 1, name: 'Adam'} ]);If I wanted to remove the duplicate records, I would then be able to use the result of
records.uniqBy('id')to get a list of just the unique records in the list.This would not alter or modify the existing
uniqmethods, it would just serve to fill in a blank.