Last active
April 20, 2017 14:04
-
-
Save feanor07/f8c6c93f066faeeac783a1f59ca36ccf to your computer and use it in GitHub Desktop.
so#43512119
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.Component.extend({ | |
isLongJobRunning: Ember.computed('result', function(){ | |
return this.get('result') === null; | |
}), | |
isLongJobNeverStarted: Ember.computed('result', function(){ | |
return this.get('result') === undefined; | |
}), | |
isLongJobFinished: Ember.computed('result', function(){ | |
return Ember.isPresent(this.get('result')); | |
}), | |
mockRemoteCallService: Ember.inject.service(), | |
actions: { | |
startLongJob() { | |
this.set('result', null); this.get('mockRemoteCallService').doLongJob().then((result)=>this.set('result', result)); | |
} | |
} | |
}); |
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({ | |
appName: 'Ember Twiddle', | |
}); |
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.Service.extend({ | |
updateProgress(percentage) { | |
this.set('percentage', `${100*percentage}%`); | |
}, | |
doLongJob() { | |
this.updateProgress(0); | |
let that = this; | |
return new Ember.RSVP.Promise( | |
function (resolve, reject) { | |
function progress(count){ | |
that.updateProgress(count/10); | |
} | |
let count = 0; | |
function timeout() { | |
window.setTimeout(function() { | |
count++; | |
if (count < 11) { | |
progress(count); | |
timeout(); | |
} else { | |
resolve(`Data returned ${Math.random()}`); | |
} | |
}, 200); | |
} | |
timeout(); | |
}); | |
} | |
}); |
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.12.1", | |
"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.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment