Last active
October 17, 2016 14:44
-
-
Save raido/f42e70e7812f3b65e75ba131f1b95370 to your computer and use it in GitHub Desktop.
Computed set with after promise resolve, proxy
This file contains hidden or 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'; | |
export default Ember.Controller.extend({ | |
_internalAppName: 'Ember Twiddle', | |
longRunningTask: new Ember.RSVP.defer(), | |
appName: Ember.computed('_internalAppName', { | |
get() { | |
return this.get('_internalAppName'); | |
}, | |
set(key, value) { | |
this.get('longRunningTask').promise.then(() => { | |
this.set('_internalAppName', value); | |
}); | |
return this.get('_internalAppName'); | |
} | |
}), | |
actions: { | |
btn() { | |
this.set('appName', 'Delayed computed setter after promise resolves'); | |
Ember.run.later(() => { | |
this.get('longRunningTask').resolve(); | |
}, 1000); | |
} | |
} | |
}); |
This file contains hidden or 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.5", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.8.0", | |
"ember-data": "2.8.0", | |
"ember-template-compiler": "2.8.0", | |
"ember-testing": "2.8.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment