Function
union (propertyKey) Ember.ComputedProperty public
Module: | @ember/object |
---|
Defined in packages/ember-runtime/lib/computed/reduce_computed_macros.js:482
import { union } from '@ember/object/computed';
- 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 one or more dependent arrays.
Example
let Hamster = Ember.Object.extend({ uniqueFruits: Ember.computed.union('fruits', 'vegetables') }); let hamster = Hamster.create({ fruits: [ 'banana', 'grape', 'kale', 'banana', 'tomato' ], vegetables: [ 'tomato', 'carrot', 'lettuce' ] }); hamster.get('uniqueFruits'); // ['banana', 'grape', 'kale', 'tomato', 'carrot', 'lettuce']
© 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/union