Function

dependentKey
String
returns
ComputedProperty
computed property which performs a logical `or` on the values of all the original values for properties.

A computed property which performs a logical or on the original values for the provided dependent properties.

You may pass in more than two properties and even use property brace expansion. The computed property will return the first truthy value or last falsy value just like JavaScript's || operator.

Example

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

let Hamster = EmberObject.extend({
  readyForRain: or('hasJacket', 'hasUmbrella'),
  readyForBeach: or('{hasSunscreen,hasUmbrella}')
});

let tomster = Hamster.create();

tomster.get('readyForRain'); // undefined
tomster.set('hasUmbrella', true);
tomster.get('readyForRain'); // true
tomster.set('hasJacket', 'Yes');
tomster.get('readyForRain'); // 'Yes'
tomster.set('hasSunscreen', 'Check');
tomster.get('readyForBeach'); // 'Check'