Function

setDiff (setAProperty, setBProperty) ComputedProperty public

Module: @ember/object
import { setDiff } from '@ember/object/computed';
setAProperty
String
setBProperty
String
returns
ComputedProperty
computes a new array with all the items from the first dependent array that are not in the second dependent array

A computed property which returns a new array with all the properties from the first dependent array that are not in the second dependent array.

Example:

import { set } from '@ember/object';
import { setDiff } from '@ember/object/computed';

class Hamster {
  constructor(likes, fruits) {
    set(this, 'likes', likes);
    set(this, 'fruits', fruits);
  }

  @setDiff('likes', 'fruits') wants;
}

let hamster = new Hamster(
  [
    'banana',
    'grape',
    'kale'
  ],
  [
    'grape',
    'kale',
  ]
);

hamster.wants; // ['banana']

Classic Class Example:

import EmberObject from '@ember/object';
import { setDiff } from '@ember/object/computed';

let Hamster = EmberObject.extend({
  wants: setDiff('likes', 'fruits')
});

let hamster = Hamster.create({
  likes: [
    'banana',
    'grape',
    'kale'
  ],
  fruits: [
    'grape',
    'kale',
  ]
});

hamster.wants; // ['banana']

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