Function

dependentKey
String
returns
ComputedProperty
computed property which returns true if the value of the dependent property is null, an empty string, empty array, or empty function and false if the underlying value is not empty.

A computed property that returns true if the value of the dependent property is null, an empty string, empty array, or empty function.

Example

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

let ToDoList = EmberObject.extend({
  isDone: empty('todos')
});

let todoList = ToDoList.create({
  todos: ['Unit Test', 'Documentation', 'Release']
});

todoList.get('isDone'); // false
todoList.get('todos').clear();
todoList.get('isDone'); // true