Function

Module: @ember/object
dependentKey
String
returns
ComputedProperty
computed property which returns inverse of the original value for property

A computed property that returns the inverse boolean value of the original value for the dependent property.

Example:

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

class User {
  loggedIn = false;
  @not('loggedIn') isAnonymous;
}

let user = new User();

user.isAnonymous; // true
set(user, 'loggedIn', true);
user.isAnonymous; // false

Classic Class Example:

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

let User = EmberObject.extend({
  loggedIn: false,

  isAnonymous: not('loggedIn')
});

let user = User.create();

user.isAnonymous; // true
set(user, 'loggedIn', true);
user.isAnonymous; // false