Function

or (dependentKey) ComputedProperty public

Module: @ember/object
import { or } from '@ember/object/computed';
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

let Hamster = Ember.Object.extend({
  readyForRain: Ember.computed.or('hasJacket', 'hasUmbrella'),
  readyForBeach: Ember.computed.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'

© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/2.18/functions/@ember%2Fobject%2Fcomputed/or