Function

uniqBy (dependentKey, propertyKey) Ember.ComputedProperty public

Module: @ember/object
import { uniqBy } from '@ember/object/computed';
dependentKey
String
propertyKey
String
returns
Ember.ComputedProperty
computes a new array with all the unique elements from the dependent array

A computed property which returns a new array with all the unique elements from an array, with uniqueness determined by specific key.

Example

let Hamster = Ember.Object.extend({
  uniqueFruits: Ember.computed.uniqBy('fruits', 'id')
});
let hamster = Hamster.create({
  fruits: [
    { id: 1, 'banana' },
    { id: 2, 'grape' },
    { id: 3, 'peach' },
    { id: 1, 'banana' }
  ]
});
hamster.get('uniqueFruits'); // [ { id: 1, 'banana' }, { id: 2, 'grape' }, { id: 3, 'peach' }]

© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/2.18/functions/@ember%2Fobject%2Fcomputed/uniqBy