Forked from krisselden/components.my-component.js
Last active
December 3, 2016 00:59
-
-
Save lukemelia/868fbd21b0532d3dfa583ca43790dde7 to your computer and use it in GitHub Desktop.
Repro readOnly CP issue II
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
import Ember from 'ember'; | |
const { computed } = Ember; | |
const { readOnly } = computed; | |
export default Ember.Component.extend({ | |
cost: readOnly('delayedCalculation.cost'), | |
tax: readOnly('delayedCalculation.tax'), | |
total: computed('cost', 'tax', function() { | |
return this.get('cost') + this.get('tax'); | |
}), | |
delayedCalculation: computed(function() { | |
let promise = Ember.RSVP.resolve({ | |
cost: 399.00, | |
tax: 32.93 | |
}); | |
return DS.PromiseObject.create({ promise }); | |
}) | |
}); |
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
import Ember from 'ember'; | |
const { computed } = Ember; | |
const { readOnly } = computed; | |
export default Ember.Component.extend({ | |
cost: readOnly('delayedCalculation.cost'), | |
tax: readOnly('delayedCalculation.tax'), | |
// One way to clear up the problem is to use the below CP definitions instead of the readOnly macros | |
// cost: computed('delayedCalculation.cost', function(){ | |
// return this.get('delayedCalculation.cost'); | |
// }), | |
// tax: computed('delayedCalculation.tax', function() { | |
// return this.get('delayedCalculation.tax') || 0; | |
// }), | |
total: computed('cost', 'tax', function() { | |
return this.get('cost') + this.get('tax'); | |
}), | |
delayedCalculation: computed(function() { | |
let promise = Ember.RSVP.resolve({ | |
cost: 399.00, | |
tax: 32.93 | |
}); | |
return DS.PromiseObject.create({ promise }); | |
}) | |
}); |
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
{ | |
"version": "0.10.6", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://s3.amazonaws.com/builds.emberjs.com/release/ember.prod.js", | |
"ember-data": "2.9.0", | |
"ember-template-compiler": "release", | |
"ember-testing": "release" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment