Ember has a ton of useful tools for writing clean, concise code. Sometimes we are so focused on the challenge at hand that we fail to utilize some of the most basic tools at our disposal. This blog is a super fast read, but will provide you (or refresh your memory) with the power of Ember Computed Macros.


These are fairly common patterns in Ember…

showDriver: computed('hasInsurance', 'hasLicense', function() {
  return this.get('hasInsurance') && this.get('hasLicense');

arrestDriver: computed('rubberNecking', 'brokenTailLight', function() {
  return this.get('rubberNecking') || this.get('brokenTailLight');

drivingAboveSpeedLimit: computed('driverSpeed', function() {
  return this.get('driverSpeed') > 65;

There is nothing functionally wrong with these computed properties. However, these patterns are so common that Ember has developed a cleaner way to handle them.


showDriver: and('hasId', 'hasLicense'),

arrestDriver: or('rubberNecking', 'brokenTailLight'),

drivingAboveSpeedLimit: gt('driverSpeed', 65),

So how do you get access to these macros… simple… just import them into your file.

import { and, or, gt } from '@ember/object/computed';

Check out the entire list of Ember Computed Macros