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.

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

let Hamster = EmberObject.extend({
  hasBananas: bool('numBananas')
});

let hamster = Hamster.create();

hamster.get('hasBananas'); // false
hamster.set('numBananas', 0);
hamster.get('hasBananas'); // false
hamster.set('numBananas', 1);
hamster.get('hasBananas'); // true
hamster.set('numBananas', null);
hamster.get('hasBananas'); // false