Function

Module: @ember/object
import { bool } from '@ember/object/computed';
dependentKey
String
returns
ComputedProperty
computed property which converts to boolean the original value for property

A computed property that converts the provided dependent property into a boolean value.

Example:

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


class Hamster {
  @bool('numBananas') hasBananas
}

let hamster = new Hamster();

hamster.hasBananas; // false

set(hamster, 'numBananas', 0);
hamster.hasBananas; // false

set(hamster, 'numBananas', 1);
hamster.hasBananas; // true

set(hamster, 'numBananas', null);
hamster.hasBananas; // false