Function
map (dependentKey, callback) ComputedProperty public
Module:
@ember/object
Defined in packages/@ember/object/lib/computed/reduce_computed_macros.js:186
import { map } from '@ember/object/computed'; |
- dependentKey
- String
- callback
- Function
- returns
- ComputedProperty
- an array mapped via the callback
Returns an array mapped via the callback
The callback method you provide should have the following signature.
item
is the current item in the iteration.
index
is the integer index of the current item in the iteration.
1 |
function(item, index); |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import { map } from '@ember/object/computed'; import EmberObject from '@ember/object'; let Hamster = EmberObject.extend({ excitingChores: map('chores', function(chore, index) { return chore.toUpperCase() + '!'; }) }); let hamster = Hamster.create({ chores: ['clean', 'write more unit tests'] }); hamster.get('excitingChores'); // ['CLEAN!', 'WRITE MORE UNIT TESTS!'] |