Function

Module: @ember/object

Available since v1.4.0

import { sum } from '@ember/object/computed';
dependentKey
String
returns
ComputedProperty
computes the sum of all values in the dependentKey's array

A computed property that returns the sum of the values in the dependent array.

Example:

1
2
3
4
5
6
7
8
9
10
11
import { sum } from '@ember/object/computed';

class Invoice {
  lineItems = [1.00, 2.50, 9.99];

  @sum('lineItems') total;
}

let invoice = new Invoice();

invoice.total; // 13.49