Last active
October 19, 2018 17:30
-
-
Save vcipriani/0661c149329ee4c647ca832bd0cad036 to your computer and use it in GitHub Desktop.
Define Property
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'; | |
import { defineProperty } from '@ember/object'; | |
export default Ember.Controller.extend({ | |
init() { | |
setTimeout(() => { | |
// This line works and is deprecated | |
this.set('delayedProperty', Ember.computed(() => 'foo')); | |
// Using defineProperty() does not trigger any computed properties that are watching the property (eg. textToShow) | |
// defineProperty(this, 'delayedProperty', Ember.computed(() => 'foo')); | |
// Just logging value for proof that delayedProperty does contain the correct value when set via defineProperty | |
console.log('Delayed Property Value is:', this.delayedProperty); | |
}, 2000); | |
}, | |
delayedProperty: 'bar', | |
textToShow: Ember.computed('delayedProperty', function() { | |
return this.get('delayedProperty'); | |
}) | |
}); |
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.15.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.2.2", | |
"ember-template-compiler": "3.2.2", | |
"ember-testing": "3.2.2" | |
}, | |
"addons": { | |
"ember-data": "3.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment