« All deprecation guides

Deprecation Guide for Deprecate import and from @ember/object/computed

until: 7.0.0
id: deprecate-import-and-from-object-computed

and from @ember/object/computed is deprecated. It previously produced the logical AND of dependent keys.

Migration

Use a getter with a standard JavaScript boolean expression.

Before:

import { and } from '@ember/object/computed';
class Cart {
  items = [];
  user = null;
  @and('items.length', 'user.isLoggedIn') canCheckout;
}

After:

class Cart {
  items = [];
  user = null;
  get canCheckout() {
    return this.items.length > 0 && this.user?.isLoggedIn;
  }
}