Function

Available since v1.13.0

import { helper } from '@ember/component/helper';
helper
Function
The helper function

In many cases, the ceremony of a full Helper class is not required. The helper method create pure-function helpers without instances. For example:

currency.js
1
2
3
4
5
6
7
import { helper } from '@ember/component/helper';

export default helper(function(params, hash) {
  let cents = params[0];
  let currency = hash.currency;
  return `${currency}${cents * 0.01}`;
});