-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add hotfix for composing class computed
- Loading branch information
Kelly Selden
committed
May 4, 2018
1 parent
ae17f21
commit 2335019
Showing
8 changed files
with
91 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import Controller from '@ember/controller'; | ||
import EmberObject, { get } from '@ember/object'; | ||
import { A as emberA } from '@ember/array'; | ||
import createClassComputed from 'ember-macro-helpers/create-class-computed'; | ||
import computed from 'ember-macro-helpers/computed'; | ||
import raw from 'ember-macro-helpers/raw'; | ||
import normalizeArrayKey from 'ember-macro-helpers/normalize-array-key'; | ||
|
||
const filterBy = createClassComputed( | ||
[false, true], | ||
(arr, key, val) => computed(normalizeArrayKey(arr, [key]), val, (arr, val) => arr.filterBy(key, val)) | ||
); | ||
|
||
export default Controller.extend({ | ||
array: emberA([ | ||
EmberObject.create({ | ||
testProp: 'test val 1', | ||
testProp2: 1 | ||
}), | ||
EmberObject.create({ | ||
testProp: 'test val 2', | ||
testProp2: 2 | ||
}) | ||
]), | ||
index: 0, | ||
testProp: 'testProp', | ||
|
||
computed: computed( | ||
filterBy('array', 'testProp', raw('test val 1')), | ||
array => get(array[array.length - 1], 'testProp2') | ||
), | ||
|
||
actions: { | ||
update() { | ||
get(this, 'array').pushObject(EmberObject.create({ | ||
testProp: 'test val 1', | ||
testProp2: 3 | ||
})); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="computed">{{computed}}</div> | ||
|
||
<button {{action "update"}}></button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters