Function

Module: @ember/object
dependentKey
String
value
String|Number|Object
returns
ComputedProperty
computed property which returns true if the original value for property is equal to the given value.

A computed property that returns true if the provided dependent property is equal to the given value.

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { set } from '@ember/object';
import { equal } from '@ember/object/computed';

class Hamster {
  @equal('percentCarrotsEaten', 100) satisfied;
}

let hamster = new Hamster();

hamster.satisfied; // false

set(hamster, 'percentCarrotsEaten', 100);
hamster.satisfied; // true

set(hamster, 'percentCarrotsEaten', 50);
hamster.satisfied; // false

Classic Class Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import EmberObject, { set } from '@ember/object';
import { equal } from '@ember/object/computed';

let Hamster = EmberObject.extend({
  satisfied: equal('percentCarrotsEaten', 100)
});

let hamster = Hamster.create();

hamster.satisfied; // false

set(hamster, 'percentCarrotsEaten', 100);
hamster.satisfied; // true

set(hamster, 'percentCarrotsEaten', 50);
hamster.satisfied; // false