Function
and (dependentKey) ComputedProperty public
Module: | @ember/object |
---|
Defined in packages/ember-runtime/lib/computed/computed_macros.js:440
import { and } from '@ember/object/computed';
- dependentKey
- String
- returns
- ComputedProperty
- computed property which performs a logical `and` on the values of all the original values for properties.
A computed property that performs a logical and
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 falsy value or last truthy value just like JavaScript's &&
operator.
Example
let Hamster = Ember.Object.extend({ readyForCamp: Ember.computed.and('hasTent', 'hasBackpack'), readyForHike: Ember.computed.and('hasWalkingStick', 'hasBackpack') }); let tomster = Hamster.create(); tomster.get('readyForCamp'); // false tomster.set('hasTent', true); tomster.get('readyForCamp'); // false tomster.set('hasBackpack', true); tomster.get('readyForCamp'); // true tomster.set('hasBackpack', 'Yes'); tomster.get('readyForCamp'); // 'Yes' tomster.set('hasWalkingStick', null); tomster.get('readyForHike'); // null
© 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/and